Issue #19512, #19515: remove shared identifiers, move identifiers where they
are used.

Move also _Py_IDENTIFIER() defintions to the top in modified files to remove
identifiers duplicated in the same file.
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 756f4ef..ec8fd12 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -80,7 +80,7 @@
 PrintError(char *msg, ...)
 {
     char buf[512];
-    PyObject *f = _PySys_GetObjectId(&_PyId_stderr);
+    PyObject *f = PySys_GetObject("stderr");
     va_list marker;
 
     va_start(marker, msg);
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 5cdd926..1f192dc 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -2578,7 +2578,7 @@
     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(
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 3ef7d65..8947889 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -185,7 +185,7 @@
             }
         }
         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);
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index a7123b7..ab0fea4 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -17,6 +17,8 @@
 static long nb_threads = 0;
 static PyObject *str_dict;
 
+_Py_IDENTIFIER(stderr);
+
 /* Lock objects */
 
 typedef struct {
@@ -1005,7 +1007,7 @@
             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
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 315b32d..27b1d54 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -26,6 +26,11 @@
    (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 @@
 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 @@
 faulthandler_env_options(void)
 {
     PyObject *xoptions, *key, *module, *res;
-    _Py_IDENTIFIER(enable);
     char *p;
 
     if (!((p = Py_GETENV("PYTHONFAULTHANDLER")) && *p != '\0')) {
diff --git a/Modules/main.c b/Modules/main.c
index 4b1a968..9171070 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -261,7 +261,7 @@
 
     /* 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;
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c
index edd12ab..9d79eec 100644
--- a/Modules/syslogmodule.c
+++ b/Modules/syslogmodule.c
@@ -71,7 +71,7 @@
     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);