mirror of https://github.com/python/cpython
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();
|
PyErr_BadInternalCall();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PyBytes_CheckExact(x)) {
|
||||||
|
Py_INCREF(x);
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
/* Use the modern buffer interface */
|
/* Use the modern buffer interface */
|
||||||
if (PyObject_CheckBuffer(x)) {
|
if (PyObject_CheckBuffer(x)) {
|
||||||
Py_buffer view;
|
Py_buffer view;
|
||||||
|
|
Loading…
Reference in New Issue