Commit 89fab1ad authored by Zackery Spytz's avatar Zackery Spytz

Add PyBytes_FromObject() and PyObject_Bytes()

The comments were taken from the CPython docs.

Closes #2713.
parent 874a7994
......@@ -68,6 +68,10 @@ cdef extern from "Python.h":
# Return value: New reference.
# Identical to PyBytes_FromFormat() except that it takes exactly two arguments.
bytes PyBytes_FromObject(object o)
# Return value: New reference.
# Return the bytes representation of object o that implements the buffer protocol.
Py_ssize_t PyBytes_Size(object string) except -1
# Return the length of the string in string object string.
......
......@@ -181,6 +181,14 @@ cdef extern from "Python.h":
# equivalent of the Python expression "str(o)". Called by the
# str() built-in function and by the print statement.
object PyObject_Bytes(object o)
# Return value: New reference.
# Compute a bytes representation of object o. Return NULL on
# failure and a bytes object on success. This is equivalent to
# the Python expression bytes(o), when o is not an integer.
# Unlike bytes(o), a TypeError is raised when o is an integer
# instead of a zero-initialized bytes object.
object PyObject_Unicode(object o)
# Return value: New reference.
# Compute a Unicode string representation of object o. Returns the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment