From: Larry Hastings Date: Fri, 25 May 2012 05:58:30 +0000 (-0700) Subject: Issue #14889: PyBytes_FromObject(bytes) now just increfs and returns. X-Git-Tag: v3.3.0a4~79 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ca28e99202cb31506c071792e463afbcdb5738f4;p=python Issue #14889: PyBytes_FromObject(bytes) now just increfs and returns. Previously, if you passed in a bytes object, it would create a whole new object. --- diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index efe6ef87b3..14bd8e68c5 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2577,6 +2577,12 @@ PyBytes_FromObject(PyObject *x) PyErr_BadInternalCall(); return NULL; } + + if (PyBytes_CheckExact(x)) { + Py_INCREF(x); + return x; + } + /* Use the modern buffer interface */ if (PyObject_CheckBuffer(x)) { Py_buffer view;