summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;