diff Objects/bytesobject.c @ 77130:f8cd75e8a1d6

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.
author Larry Hastings <larry@hastings.org>
date Thu, 24 May 2012 22:58:30 -0700
parents f4837725c50f
children 8fbbc7c8748e
line wrap: on
line diff
--- a/Objects/bytesobject.c	Thu May 24 22:54:15 2012 -0700
+++ b/Objects/bytesobject.c	Thu May 24 22:58:30 2012 -0700
@@ -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;