bpo-39487: Merge duplicated _Py_IDENTIFIER identifiers in C code (GH-18254)

Moving repetitive `_Py_IDENTIFIER` instances to a global location helps identify them more easily in regards to sub-interpreter support.
This commit is contained in:
Hai Shi 2020-01-30 17:20:25 -06:00 committed by GitHub
parent c232c9110c
commit 46874c26ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 24 additions and 34 deletions

View file

@ -25,6 +25,8 @@ Py_ssize_t _Py_null_strings, _Py_one_strings;
static PyBytesObject *characters[UCHAR_MAX + 1];
static PyBytesObject *nullstring;
_Py_IDENTIFIER(__bytes__);
/* PyBytesObject_SIZE gives the basic size of a string; any memory allocation
for a string of length n should request PyBytesObject_SIZE + n bytes.
@ -543,7 +545,6 @@ static PyObject *
format_obj(PyObject *v, const char **pbuf, Py_ssize_t *plen)
{
PyObject *func, *result;
_Py_IDENTIFIER(__bytes__);
/* is it a bytes object? */
if (PyBytes_Check(v)) {
*pbuf = PyBytes_AS_STRING(v);
@ -2485,7 +2486,6 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *func;
Py_ssize_t size;
static char *kwlist[] = {"source", "encoding", "errors", 0};
_Py_IDENTIFIER(__bytes__);
if (type != &PyBytes_Type)
return bytes_subtype_new(type, args, kwds);