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.
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index f9823f1..5fd92f7 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -25,6 +25,8 @@
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 @@
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 @@
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);