]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #19512, #19515: remove shared identifiers, move identifiers where they
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 7 Nov 2013 22:07:29 +0000 (23:07 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 7 Nov 2013 22:07:29 +0000 (23:07 +0100)
are used.

Move also _Py_IDENTIFIER() defintions to the top in modified files to remove
identifiers duplicated in the same file.

17 files changed:
Include/object.h
Modules/_ctypes/callbacks.c
Modules/_cursesmodule.c
Modules/_lsprof.c
Modules/_threadmodule.c
Modules/faulthandler.c
Modules/main.c
Modules/syslogmodule.c
Objects/object.c
Objects/typeobject.c
Python/_warnings.c
Python/bltinmodule.c
Python/errors.c
Python/import.c
Python/pythonrun.c
Python/sysmodule.c
Python/traceback.c

index 27f48a5ba9a73ae0198f6e0eac2cb22c56e25117..a6130fe2b85c35dc2aa928645a4dc01405ff6c85 100644 (file)
@@ -147,14 +147,6 @@ typedef struct _Py_Identifier {
 #define _Py_static_string(varname, value)  static _Py_Identifier varname = _Py_static_string_init(value)
 #define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname)
 
-/* Common identifiers (ex: _PyId_path is the string "path") */
-PyAPI_DATA(_Py_Identifier) _PyId_argv;
-PyAPI_DATA(_Py_Identifier) _PyId_builtins;
-PyAPI_DATA(_Py_Identifier) _PyId_path;
-PyAPI_DATA(_Py_Identifier) _PyId_stdin;
-PyAPI_DATA(_Py_Identifier) _PyId_stdout;
-PyAPI_DATA(_Py_Identifier) _PyId_stderr;
-
 /*
 Type objects contain a string containing the type name (to help somewhat
 in debugging), the allocation parameters (see PyObject_New() and
index 756f4efbc9dfc961da156b4da74eec975a7a9fc6..ec8fd12a8969587d792a7d13dd7b7378119f3675 100644 (file)
@@ -80,7 +80,7 @@ static void
 PrintError(char *msg, ...)
 {
     char buf[512];
-    PyObject *f = _PySys_GetObjectId(&_PyId_stderr);
+    PyObject *f = PySys_GetObject("stderr");
     va_list marker;
 
     va_start(marker, msg);
index 5cdd9260af4ac06d8aa58d9083cce94e33c67a48..1f192dc73c8b0611b6e520a213232d80844f6186 100644 (file)
@@ -2578,7 +2578,7 @@ PyCurses_setupterm(PyObject* self, PyObject *args, PyObject* keywds)
     if (fd == -1) {
         PyObject* sys_stdout;
 
-        sys_stdout = _PySys_GetObjectId(&_PyId_stdout);
+        sys_stdout = PySys_GetObject("stdout");
 
         if (sys_stdout == NULL || sys_stdout == Py_None) {
             PyErr_SetString(
index 3ef7d65e490a762153679783189cbfc926bb148d..894788916d7e2ca6d0aced3b290e22e8aa1c0355 100644 (file)
@@ -185,7 +185,7 @@ normalizeUserObj(PyObject *obj)
             }
         }
         if (modname != NULL) {
-            if (_PyUnicode_CompareWithId(modname, &_PyId_builtins) != 0) {
+            if (PyUnicode_CompareWithASCIIString(modname, "builtins") != 0) {
                 PyObject *result;
                 result = PyUnicode_FromFormat("<%U.%s>", modname,
                                               fn->m_ml->ml_name);
index a7123b7ee5669cad38314e148928418f722227d9..ab0fea44e419f2bd9a18c796a2f03f43cd5710a7 100644 (file)
@@ -17,6 +17,8 @@ static PyObject *ThreadError;
 static long nb_threads = 0;
 static PyObject *str_dict;
 
+_Py_IDENTIFIER(stderr);
+
 /* Lock objects */
 
 typedef struct {
@@ -1005,7 +1007,7 @@ t_bootstrap(void *boot_raw)
             PySys_WriteStderr(
                 "Unhandled exception in thread started by ");
             PyErr_Fetch(&exc, &value, &tb);
-            file = _PySys_GetObjectId(&_PyId_stderr);
+            file = _PySys_GetObjectId(&PyId_stderr);
             if (file != NULL && file != Py_None)
                 PyFile_WriteObject(boot->func, file, 0);
             else
index 315b32da38f43aae835db11d3eb9b9876bf0b4bd..27b1d54c60ccbb02395c9a498bd3f9812abdec14 100644 (file)
    (anyway, the length is smaller than 30 characters) */
 #define PUTS(fd, str) write(fd, str, (int)strlen(str))
 
+_Py_IDENTIFIER(enable);
+_Py_IDENTIFIER(fileno);
+_Py_IDENTIFIER(flush);
+_Py_IDENTIFIER(stderr);
+
 #ifdef HAVE_SIGACTION
 typedef struct sigaction _Py_sighandler_t;
 #else
@@ -130,13 +135,11 @@ static PyObject*
 faulthandler_get_fileno(PyObject *file, int *p_fd)
 {
     PyObject *result;
-    _Py_IDENTIFIER(fileno);
-    _Py_IDENTIFIER(flush);
     long fd_long;
     int fd;
 
     if (file == NULL || file == Py_None) {
-        file = _PySys_GetObjectId(&_PyId_stderr);
+        file = _PySys_GetObjectId(&PyId_stderr);
         if (file == NULL) {
             PyErr_SetString(PyExc_RuntimeError, "unable to get sys.stderr");
             return NULL;
@@ -1047,7 +1050,6 @@ static int
 faulthandler_env_options(void)
 {
     PyObject *xoptions, *key, *module, *res;
-    _Py_IDENTIFIER(enable);
     char *p;
 
     if (!((p = Py_GETENV("PYTHONFAULTHANDLER")) && *p != '\0')) {
index 4b1a9681b9b55a93d781a3c5c4b98bb470255906..9171070ab5dd2f4ee731981c1b17f91edc5e1edc 100644 (file)
@@ -261,7 +261,7 @@ RunMainFromImporter(wchar_t *filename)
 
     /* argv0 is usable as an import source, so put it in sys.path[0]
        and import __main__ */
-    sys_path = _PySys_GetObjectId(&_PyId_path);
+    sys_path = PySys_GetObject("path");
     if (sys_path == NULL) {
         PyErr_SetString(PyExc_RuntimeError, "unable to get sys.path");
         goto error;
index edd12abb98f8c2efc79721c81312c50b243642f6..9d79eec52a38a5dab6e8bc40b59c2e074e7e045e 100644 (file)
@@ -71,7 +71,7 @@ syslog_get_argv(void)
     Py_ssize_t argv_len, scriptlen;
     PyObject *scriptobj;
     Py_ssize_t slash;
-    PyObject *argv = _PySys_GetObjectId(&_PyId_argv);
+    PyObject *argv = PySys_GetObject("argv");
 
     if (argv == NULL) {
         return(NULL);
index 9d96e86c589827cd75f49a5c889b1ea0c049f663..acc34af3499279b9f12567e7c9e0a15f9e329c91 100644 (file)
@@ -8,6 +8,12 @@
 extern "C" {
 #endif
 
+_Py_IDENTIFIER(Py_Repr);
+_Py_IDENTIFIER(__bytes__);
+_Py_IDENTIFIER(__dir__);
+_Py_IDENTIFIER(__isabstractmethod__);
+_Py_IDENTIFIER(builtins);
+
 #ifdef Py_REF_DEBUG
 Py_ssize_t _Py_RefTotal;
 
@@ -560,7 +566,6 @@ PyObject *
 PyObject_Bytes(PyObject *v)
 {
     PyObject *result, *func;
-    _Py_IDENTIFIER(__bytes__);
 
     if (v == NULL)
         return PyBytes_FromString("<NULL>");
@@ -949,7 +954,6 @@ _PyObject_IsAbstract(PyObject *obj)
 {
     int res;
     PyObject* isabstract;
-    _Py_IDENTIFIER(__isabstractmethod__);
 
     if (obj == NULL)
         return 0;
@@ -1124,7 +1128,7 @@ _PyObject_GetBuiltin(const char *name)
 {
     PyObject *mod_name, *mod, *attr;
 
-    mod_name = _PyUnicode_FromId(&_PyId_builtins);   /* borrowed */
+    mod_name = _PyUnicode_FromId(&PyId_builtins);   /* borrowed */
     if (mod_name == NULL)
         return NULL;
     mod = PyImport_Import(mod_name);
@@ -1440,7 +1444,6 @@ static PyObject *
 _dir_object(PyObject *obj)
 {
     PyObject *result, *sorted;
-    _Py_IDENTIFIER(__dir__);
     PyObject *dirfunc = _PyObject_LookupSpecial(obj, &PyId___dir__);
 
     assert(obj);
@@ -1973,8 +1976,6 @@ _PyObject_DebugTypeStats(FILE *out)
    See dictobject.c and listobject.c for examples of use.
 */
 
-_Py_IDENTIFIER(Py_Repr);
-
 int
 Py_ReprEnter(PyObject *obj)
 {
index 8bccb68692800df8900027f33be138b3e8f8cc22..0708d678e18a6dc10513033f8ecec6f001b863dd 100644 (file)
@@ -53,6 +53,7 @@ _Py_IDENTIFIER(__module__);
 _Py_IDENTIFIER(__name__);
 _Py_IDENTIFIER(__new__);
 _Py_IDENTIFIER(__setitem__);
+_Py_IDENTIFIER(builtins);
 
 static PyObject *
 slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
@@ -366,7 +367,7 @@ type_module(PyTypeObject *type, void *context)
         if (s != NULL)
             return PyUnicode_FromStringAndSize(
                 type->tp_name, (Py_ssize_t)(s - type->tp_name));
-        name = _PyUnicode_FromId(&_PyId_builtins);
+        name = _PyUnicode_FromId(&PyId_builtins);
         Py_XINCREF(name);
         return name;
     }
@@ -718,7 +719,7 @@ type_repr(PyTypeObject *type)
         return NULL;
     }
 
-    if (mod != NULL && _PyUnicode_CompareWithId(mod, &_PyId_builtins))
+    if (mod != NULL && _PyUnicode_CompareWithId(mod, &PyId_builtins))
         rtn = PyUnicode_FromFormat("<class '%U.%U'>", mod, name);
     else
         rtn = PyUnicode_FromFormat("<class '%s'>", type->tp_name);
@@ -3189,7 +3190,7 @@ object_repr(PyObject *self)
         Py_XDECREF(mod);
         return NULL;
     }
-    if (mod != NULL && _PyUnicode_CompareWithId(mod, &_PyId_builtins))
+    if (mod != NULL && _PyUnicode_CompareWithId(mod, &PyId_builtins))
         rtn = PyUnicode_FromFormat("<%U.%U object at %p>", mod, name, self);
     else
         rtn = PyUnicode_FromFormat("<%s object at %p>",
index de601281be4c03ad395adff46efc0b65a8f6dfe1..6013d7d7d48c055da3d8fdabc313469efe4f3a8d 100644 (file)
@@ -13,6 +13,8 @@ static PyObject *_filters;  /* List */
 static PyObject *_once_registry;  /* Dict */
 static PyObject *_default_action; /* String */
 
+_Py_IDENTIFIER(argv);
+_Py_IDENTIFIER(stderr);
 
 static int
 check_matched(PyObject *obj, PyObject *arg)
@@ -265,7 +267,7 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
     if (name == NULL)  /* XXX Can an object lack a '__name__' attribute? */
         goto error;
 
-    f_stderr = _PySys_GetObjectId(&_PyId_stderr);
+    f_stderr = _PySys_GetObjectId(&PyId_stderr);
     if (f_stderr == NULL) {
         fprintf(stderr, "lost sys.stderr\n");
         goto error;
@@ -562,7 +564,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
     else {
         *filename = NULL;
         if (*module != Py_None && PyUnicode_CompareWithASCIIString(*module, "__main__") == 0) {
-            PyObject *argv = _PySys_GetObjectId(&_PyId_argv);
+            PyObject *argv = _PySys_GetObjectId(&PyId_argv);
             /* PyList_Check() is needed because sys.argv is set to None during
                Python finalization */
             if (argv != NULL && PyList_Check(argv) && PyList_Size(argv) > 0) {
index 7f3593c69521eef0a234f8703e7628869911159d..96ccd6422d29e6f215faf23bff093ea050142d2f 100644 (file)
@@ -32,9 +32,19 @@ const char *Py_FileSystemDefaultEncoding = NULL; /* set by initfsencoding() */
 int Py_HasFileSystemDefaultEncoding = 0;
 #endif
 
+_Py_IDENTIFIER(__builtins__);
+_Py_IDENTIFIER(__dict__);
+_Py_IDENTIFIER(__prepare__);
+_Py_IDENTIFIER(__round__);
+_Py_IDENTIFIER(encoding);
+_Py_IDENTIFIER(errors);
 _Py_IDENTIFIER(fileno);
 _Py_IDENTIFIER(flush);
-_Py_IDENTIFIER(__builtins__);
+_Py_IDENTIFIER(metaclass);
+_Py_IDENTIFIER(sort);
+_Py_IDENTIFIER(stdin);
+_Py_IDENTIFIER(stdout);
+_Py_IDENTIFIER(stderr);
 
 static PyObject *
 builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
@@ -43,8 +53,6 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
     PyObject *cls = NULL;
     Py_ssize_t nargs;
     int isclass;
-    _Py_IDENTIFIER(__prepare__);
-    _Py_IDENTIFIER(metaclass);
 
     assert(args != NULL);
     if (!PyTuple_Check(args)) {
@@ -1547,7 +1555,6 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
     static PyObject *dummy_args;
     PyObject *sep = NULL, *end = NULL, *file = NULL, *flush = NULL;
     int i, err;
-    _Py_IDENTIFIER(flush);
 
     if (dummy_args == NULL && !(dummy_args = PyTuple_New(0)))
         return NULL;
@@ -1555,7 +1562,7 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
                                      kwlist, &sep, &end, &file, &flush))
         return NULL;
     if (file == NULL || file == Py_None) {
-        file = _PySys_GetObjectId(&_PyId_stdout);
+        file = _PySys_GetObjectId(&PyId_stdout);
         if (file == NULL) {
             PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
             return NULL;
@@ -1640,9 +1647,9 @@ static PyObject *
 builtin_input(PyObject *self, PyObject *args)
 {
     PyObject *promptarg = NULL;
-    PyObject *fin = _PySys_GetObjectId(&_PyId_stdin);
-    PyObject *fout = _PySys_GetObjectId(&_PyId_stdout);
-    PyObject *ferr = _PySys_GetObjectId(&_PyId_stderr);
+    PyObject *fin = _PySys_GetObjectId(&PyId_stdin);
+    PyObject *fout = _PySys_GetObjectId(&PyId_stdout);
+    PyObject *ferr = _PySys_GetObjectId(&PyId_stderr);
     PyObject *tmp;
     long fd;
     int tty;
@@ -1713,8 +1720,6 @@ builtin_input(PyObject *self, PyObject *args)
         char *stdin_encoding_str, *stdin_errors_str;
         PyObject *result;
         size_t len;
-        _Py_IDENTIFIER(encoding);
-        _Py_IDENTIFIER(errors);
 
         stdin_encoding = _PyObject_GetAttrId(fin, &PyId_encoding);
         stdin_errors = _PyObject_GetAttrId(fin, &PyId_errors);
@@ -1843,7 +1848,6 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
     PyObject *ndigits = NULL;
     static char *kwlist[] = {"number", "ndigits", 0};
     PyObject *number, *round, *result;
-    _Py_IDENTIFIER(__round__);
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:round",
                                      kwlist, &number, &ndigits))
@@ -1886,7 +1890,6 @@ builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds)
     PyObject *callable;
     static char *kwlist[] = {"iterable", "key", "reverse", 0};
     int reverse;
-    _Py_IDENTIFIER(sort);
 
     /* args 1-3 should match listsort in Objects/listobject.c */
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Oi:sorted",
@@ -1939,7 +1942,6 @@ builtin_vars(PyObject *self, PyObject *args)
         Py_INCREF(d);
     }
     else {
-        _Py_IDENTIFIER(__dict__);
         d = _PyObject_GetAttrId(v, &PyId___dict__);
         if (d == NULL) {
             PyErr_SetString(PyExc_TypeError,
index 93e47246803bd5c24b4fa5656d216d6418f7937f..90dc729fd1d1f8cb9b95d9f353905a28939bf54b 100644 (file)
@@ -20,6 +20,9 @@ extern char *strerror(int);
 extern "C" {
 #endif
 
+_Py_IDENTIFIER(builtins);
+_Py_IDENTIFIER(stderr);
+
 
 void
 PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
@@ -844,7 +847,7 @@ PyErr_WriteUnraisable(PyObject *obj)
 
     PyErr_Fetch(&t, &v, &tb);
 
-    f = _PySys_GetObjectId(&_PyId_stderr);
+    f = _PySys_GetObjectId(&PyId_stderr);
     if (f == NULL || f == Py_None)
         goto done;
 
@@ -878,7 +881,7 @@ PyErr_WriteUnraisable(PyObject *obj)
             goto done;
     }
     else {
-        if (_PyUnicode_CompareWithId(moduleName, &_PyId_builtins) != 0) {
+        if (_PyUnicode_CompareWithId(moduleName, &PyId_builtins) != 0) {
             if (PyFile_WriteObject(moduleName, f, Py_PRINT_RAW) < 0)
                 goto done;
             if (PyFile_WriteString(".", f) < 0)
index aea29e28f307bdb1ce8a03ab3ab88ad74a10fedd..c96106f373265b44282c06e0dbc45ed3a6bd2e5b 100644 (file)
@@ -310,7 +310,7 @@ PyImport_Cleanup(void)
 
     /* XXX Perhaps these precautions are obsolete. Who knows? */
 
-    value = _PyDict_GetItemId(modules, &_PyId_builtins);
+    value = PyDict_GetItemString(modules, "builtins");
     if (value != NULL && PyModule_Check(value)) {
         dict = PyModule_GetDict(value);
         if (Py_VerboseFlag)
index 5115c5724c2d7e664db9d3ecdb09f833e7b50c08..922446ecf6c531deac144b8d4656653372248ca3 100644 (file)
 #define PATH_MAX MAXPATHLEN
 #endif
 
-/* Common identifiers */
-_Py_Identifier _PyId_argv = _Py_static_string_init("argv");
-_Py_Identifier _PyId_builtins = _Py_static_string_init("builtins");
-_Py_Identifier _PyId_path = _Py_static_string_init("path");
-_Py_Identifier _PyId_stdin = _Py_static_string_init("stdin");
-_Py_Identifier _PyId_stdout = _Py_static_string_init("stdout");
-_Py_Identifier _PyId_stderr = _Py_static_string_init("stderr");
-
-/* local identifiers */
+_Py_IDENTIFIER(builtins);
 _Py_IDENTIFIER(excepthook);
-_Py_IDENTIFIER(ps1);
-_Py_IDENTIFIER(ps2);
+_Py_IDENTIFIER(last_traceback);
 _Py_IDENTIFIER(last_type);
 _Py_IDENTIFIER(last_value);
-_Py_IDENTIFIER(last_traceback);
+_Py_IDENTIFIER(ps1);
+_Py_IDENTIFIER(ps2);
+_Py_IDENTIFIER(stdin);
+_Py_IDENTIFIER(stdout);
+_Py_IDENTIFIER(stderr);
 _Py_static_string(PyId_string, "<string>");
 
 #ifdef Py_REF_DEBUG
@@ -429,7 +424,7 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib)
     pstderr = PyFile_NewStdPrinter(fileno(stderr));
     if (pstderr == NULL)
         Py_FatalError("Py_Initialize: can't set preliminary stderr");
-    _PySys_SetObjectId(&_PyId_stderr, pstderr);
+    _PySys_SetObjectId(&PyId_stderr, pstderr);
     PySys_SetObject("__stderr__", pstderr);
     Py_DECREF(pstderr);
 
@@ -514,8 +509,8 @@ file_is_closed(PyObject *fobj)
 static void
 flush_std_files(void)
 {
-    PyObject *fout = _PySys_GetObjectId(&_PyId_stdout);
-    PyObject *ferr = _PySys_GetObjectId(&_PyId_stderr);
+    PyObject *fout = _PySys_GetObjectId(&PyId_stdout);
+    PyObject *ferr = _PySys_GetObjectId(&PyId_stderr);
     PyObject *tmp;
     _Py_IDENTIFIER(flush);
 
@@ -793,7 +788,7 @@ Py_NewInterpreter(void)
         pstderr = PyFile_NewStdPrinter(fileno(stderr));
         if (pstderr == NULL)
             Py_FatalError("Py_Initialize: can't set preliminary stderr");
-        _PySys_SetObjectId(&_PyId_stderr, pstderr);
+        _PySys_SetObjectId(&PyId_stderr, pstderr);
         PySys_SetObject("__stderr__", pstderr);
         Py_DECREF(pstderr);
 
@@ -1187,7 +1182,7 @@ initstdio(void)
             goto error;
     } /* if (fd < 0) */
     PySys_SetObject("__stdin__", std);
-    _PySys_SetObjectId(&_PyId_stdin, std);
+    _PySys_SetObjectId(&PyId_stdin, std);
     Py_DECREF(std);
 
     /* Set sys.stdout */
@@ -1202,7 +1197,7 @@ initstdio(void)
             goto error;
     } /* if (fd < 0) */
     PySys_SetObject("__stdout__", std);
-    _PySys_SetObjectId(&_PyId_stdout, std);
+    _PySys_SetObjectId(&PyId_stdout, std);
     Py_DECREF(std);
 
 #if 1 /* Disable this if you have trouble debugging bootstrap stuff */
@@ -1236,7 +1231,7 @@ initstdio(void)
         Py_DECREF(std);
         goto error;
     }
-    if (_PySys_SetObjectId(&_PyId_stderr, std) < 0) {
+    if (_PySys_SetObjectId(&PyId_stderr, std) < 0) {
         Py_DECREF(std);
         goto error;
     }
@@ -1368,7 +1363,7 @@ PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)
 
     if (fp == stdin) {
         /* Fetch encoding from sys.stdin if possible. */
-        v = _PySys_GetObjectId(&_PyId_stdin);
+        v = _PySys_GetObjectId(&PyId_stdin);
         if (v && v != Py_None) {
             oenc = _PyObject_GetAttrId(v, &PyId_encoding);
             if (oenc)
@@ -1774,7 +1769,7 @@ handle_system_exit(void)
     if (PyLong_Check(value))
         exitcode = (int)PyLong_AsLong(value);
     else {
-        PyObject *sys_stderr = _PySys_GetObjectId(&_PyId_stderr);
+        PyObject *sys_stderr = _PySys_GetObjectId(&PyId_stderr);
         if (sys_stderr != NULL && sys_stderr != Py_None) {
             PyFile_WriteObject(value, sys_stderr, Py_PRINT_RAW);
         } else {
@@ -1938,7 +1933,7 @@ print_exception(PyObject *f, PyObject *value)
             err = PyFile_WriteString("<unknown>", f);
         }
         else {
-            if (_PyUnicode_CompareWithId(moduleName, &_PyId_builtins) != 0)
+            if (_PyUnicode_CompareWithId(moduleName, &PyId_builtins) != 0)
             {
                 err = PyFile_WriteObject(moduleName, f, Py_PRINT_RAW);
                 err += PyFile_WriteString(".", f);
@@ -2033,7 +2028,7 @@ void
 PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
 {
     PyObject *seen;
-    PyObject *f = _PySys_GetObjectId(&_PyId_stderr);
+    PyObject *f = _PySys_GetObjectId(&PyId_stderr);
     if (PyExceptionInstance_Check(value)
         && tb != NULL && PyTraceBack_Check(tb)) {
         /* Put the traceback on the exception, otherwise it won't get
@@ -2130,7 +2125,7 @@ flush_io(void)
     /* Save the current exception */
     PyErr_Fetch(&type, &value, &traceback);
 
-    f = _PySys_GetObjectId(&_PyId_stderr);
+    f = _PySys_GetObjectId(&PyId_stderr);
     if (f != NULL) {
         r = _PyObject_CallMethodId(f, &PyId_flush, "");
         if (r)
@@ -2138,7 +2133,7 @@ flush_io(void)
         else
             PyErr_Clear();
     }
-    f = _PySys_GetObjectId(&_PyId_stdout);
+    f = _PySys_GetObjectId(&PyId_stdout);
     if (f != NULL) {
         r = _PyObject_CallMethodId(f, &PyId_flush, "");
         if (r)
index de33d558358a147a603db88d0ca31465f88a2138..3ebb6c9493aa022a73fc02c4016eebdb046cea5c 100644 (file)
@@ -41,6 +41,16 @@ extern const char *PyWin_DLLVersionString;
 #include <langinfo.h>
 #endif
 
+_Py_IDENTIFIER(_);
+_Py_IDENTIFIER(__sizeof__);
+_Py_IDENTIFIER(buffer);
+_Py_IDENTIFIER(builtins);
+_Py_IDENTIFIER(encoding);
+_Py_IDENTIFIER(path);
+_Py_IDENTIFIER(stdout);
+_Py_IDENTIFIER(stderr);
+_Py_IDENTIFIER(write);
+
 PyObject *
 _PySys_GetObjectId(_Py_Identifier *key)
 {
@@ -104,8 +114,6 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o)
     PyObject *encoded, *escaped_str, *repr_str, *buffer, *result;
     char *stdout_encoding_str;
     int ret;
-    _Py_IDENTIFIER(encoding);
-    _Py_IDENTIFIER(buffer);
 
     stdout_encoding = _PyObject_GetAttrId(outf, &PyId_encoding);
     if (stdout_encoding == NULL)
@@ -126,7 +134,6 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o)
 
     buffer = _PyObject_GetAttrId(outf, &PyId_buffer);
     if (buffer) {
-        _Py_IDENTIFIER(write);
         result = _PyObject_CallMethodId(buffer, &PyId_write, "(O)", encoded);
         Py_DECREF(buffer);
         Py_DECREF(encoded);
@@ -165,8 +172,6 @@ sys_displayhook(PyObject *self, PyObject *o)
     PyObject *builtins;
     static PyObject *newline = NULL;
     int err;
-    _Py_IDENTIFIER(_);
-    _Py_IDENTIFIER(builtins);
 
     builtins = _PyDict_GetItemId(modules, &PyId_builtins);
     if (builtins == NULL) {
@@ -183,7 +188,7 @@ sys_displayhook(PyObject *self, PyObject *o)
     }
     if (_PyObject_SetAttrId(builtins, &PyId__, Py_None) != 0)
         return NULL;
-    outf = _PySys_GetObjectId(&_PyId_stdout);
+    outf = _PySys_GetObjectId(&PyId_stdout);
     if (outf == NULL || outf == Py_None) {
         PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
         return NULL;
@@ -854,7 +859,6 @@ sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds)
     static char *kwlist[] = {"object", "default", 0};
     PyObject *o, *dflt = NULL;
     PyObject *method;
-    _Py_IDENTIFIER(__sizeof__);
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:getsizeof",
                                      kwlist, &o, &dflt))
@@ -1825,7 +1829,7 @@ PySys_SetPath(const wchar_t *path)
     PyObject *v;
     if ((v = makepathobject(path, DELIM)) == NULL)
         Py_FatalError("can't create sys.path");
-    if (_PySys_SetObjectId(&_PyId_path, v) != 0)
+    if (_PySys_SetObjectId(&PyId_path, v) != 0)
         Py_FatalError("can't assign sys.path");
     Py_DECREF(v);
 }
@@ -1894,7 +1898,7 @@ sys_update_path(int argc, wchar_t **argv)
     wchar_t fullpath[MAX_PATH];
 #endif
 
-    path = _PySys_GetObjectId(&_PyId_path);
+    path = _PySys_GetObjectId(&PyId_path);
     if (path == NULL)
         return;
 
@@ -2004,7 +2008,6 @@ sys_pyfile_write_unicode(PyObject *unicode, PyObject *file)
 {
     PyObject *writer = NULL, *args = NULL, *result = NULL;
     int err;
-    _Py_IDENTIFIER(write);
 
     if (file == NULL)
         return -1;
@@ -2109,7 +2112,7 @@ PySys_WriteStdout(const char *format, ...)
     va_list va;
 
     va_start(va, format);
-    sys_write(&_PyId_stdout, stdout, format, va);
+    sys_write(&PyId_stdout, stdout, format, va);
     va_end(va);
 }
 
@@ -2119,7 +2122,7 @@ PySys_WriteStderr(const char *format, ...)
     va_list va;
 
     va_start(va, format);
-    sys_write(&_PyId_stderr, stderr, format, va);
+    sys_write(&PyId_stderr, stderr, format, va);
     va_end(va);
 }
 
@@ -2151,7 +2154,7 @@ PySys_FormatStdout(const char *format, ...)
     va_list va;
 
     va_start(va, format);
-    sys_format(&_PyId_stdout, stdout, format, va);
+    sys_format(&PyId_stdout, stdout, format, va);
     va_end(va);
 }
 
@@ -2161,6 +2164,6 @@ PySys_FormatStderr(const char *format, ...)
     va_list va;
 
     va_start(va, format);
-    sys_format(&_PyId_stderr, stderr, format, va);
+    sys_format(&PyId_stderr, stderr, format, va);
     va_end(va);
 }
index b0bed5f7800a66619f7d44036f472dfc8157075c..e9169ce5e060db79afa7aecee9bdeefbf5181bfc 100644 (file)
 /* Function from Parser/tokenizer.c */
 extern char * PyTokenizer_FindEncodingFilename(int, PyObject *);
 
+_Py_IDENTIFIER(TextIOWrapper);
+_Py_IDENTIFIER(close);
+_Py_IDENTIFIER(open);
+_Py_IDENTIFIER(path);
+
 static PyObject *
 tb_dir(PyTracebackObject *self)
 {
@@ -152,7 +157,6 @@ _Py_FindSourceFile(PyObject *filename, char* namebuf, size_t namelen, PyObject *
     const char* filepath;
     Py_ssize_t len;
     PyObject* result;
-    _Py_IDENTIFIER(open);
 
     filebytes = PyUnicode_EncodeFSDefault(filename);
     if (filebytes == NULL) {
@@ -169,7 +173,7 @@ _Py_FindSourceFile(PyObject *filename, char* namebuf, size_t namelen, PyObject *
         tail++;
     taillen = strlen(tail);
 
-    syspath = _PySys_GetObjectId(&_PyId_path);
+    syspath = _PySys_GetObjectId(&PyId_path);
     if (syspath == NULL || !PyList_Check(syspath))
         goto error;
     npath = PyList_Size(syspath);
@@ -232,9 +236,6 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
     char buf[MAXPATHLEN+1];
     int kind;
     void *data;
-    _Py_IDENTIFIER(close);
-    _Py_IDENTIFIER(open);
-    _Py_IDENTIFIER(TextIOWrapper);
 
     /* open the file */
     if (filename == NULL)