diff options
author | Larry Hastings <larry@hastings.org> | 2012-05-25 05:58:30 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2012-05-25 05:58:30 (GMT) |
commit | ca28e99202cb31506c071792e463afbcdb5738f4 (patch) | |
tree | 088e14a0fda2cc1ac41a6065f6a97ca7136ca6d1 | |
parent | 5ed7bd79dfec6b1ef203f022ef662573a93085c4 (diff) | |
download | cpython-ca28e99202cb31506c071792e463afbcdb5738f4.zip cpython-ca28e99202cb31506c071792e463afbcdb5738f4.tar.gz cpython-ca28e99202cb31506c071792e463afbcdb5738f4.tar.bz2 |
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.
-rw-r--r-- | Objects/bytesobject.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index efe6ef8..14bd8e6 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; |