mirror of
https://github.com/python/cpython.git
synced 2024-12-03 23:06:43 +08:00
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.
This commit is contained in:
parent
5ed7bd79df
commit
ca28e99202
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user