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/fileobject.c b/Objects/fileobject.c
index 3ec5a00..527693c 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -25,6 +25,8 @@
extern "C" {
#endif
+_Py_IDENTIFIER(open);
+
/* External C interface */
PyObject *
@@ -32,7 +34,6 @@
const char *errors, const char *newline, int closefd)
{
PyObject *io, *stream;
- _Py_IDENTIFIER(open);
/* import _io in case we are being used to open io.py */
io = PyImport_ImportModule("_io");
@@ -547,7 +548,6 @@
PyFile_OpenCodeObject(PyObject *path)
{
PyObject *iomod, *f = NULL;
- _Py_IDENTIFIER(open);
if (!PyUnicode_Check(path)) {
PyErr_Format(PyExc_TypeError, "'path' must be 'str', not '%.200s'",