[Python-checkins] cpython: Issue #14889: PyBytes_FromObject(bytes) now just increfs and returns.
larry.hastings
python-checkins at python.org
Fri May 25 07:58:47 CEST 2012
http://hg.python.org/cpython/rev/f8cd75e8a1d6
changeset: 77130:f8cd75e8a1d6
user: Larry Hastings <larry at hastings.org>
date: Thu May 24 22:58:30 2012 -0700
summary:
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.
files:
Objects/bytesobject.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -2577,6 +2577,12 @@
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;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list