summaryrefslogtreecommitdiff
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2012-05-24 22:58:30 -0700
committerLarry Hastings <larry@hastings.org>2012-05-24 22:58:30 -0700
commitca28e99202cb31506c071792e463afbcdb5738f4 (patch)
tree088e14a0fda2cc1ac41a6065f6a97ca7136ca6d1 /Objects/bytesobject.c
parent5ed7bd79dfec6b1ef203f022ef662573a93085c4 (diff)
downloadcpython-git-ca28e99202cb31506c071792e463afbcdb5738f4.tar.gz
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.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c6
1 files changed, 6 insertions, 0 deletions
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;