make bytes(o) respect __bytes__ #2415

This adds two new C-API functions: PyObject_Bytes and PyBytes_FromObject.

Reviewer: Barry
diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst
index 193ab95..7b9682c 100644
--- a/Doc/c-api/object.rst
+++ b/Doc/c-api/object.rst
@@ -139,6 +139,14 @@
    Python expression ``str(o)``.  Called by the :func:`str` built-in function
    and, therefore, by the :func:`print` function.
 
+.. cfunction:: PyObject* PyObject_Bytes(PyObject *o)
+
+   .. index:: builtin: bytes
+
+   Compute a bytes representation of object *o*.  *NULL* is returned on failure
+   and a bytes object on success.  This is equivalent to the Python expression
+   ``bytes(o)``.
+
 
 .. cfunction:: int PyObject_IsInstance(PyObject *inst, PyObject *cls)