diff Python/import.c @ 68710:b50a0d44545a

Issue #3080: PyImport_Cleanup() uses Unicode Replace strcmp() by PyUnicode_CompareWithASCIIString()
author Victor Stinner <victor.stinner@haypocalc.com>
date Mon, 07 Mar 2011 17:08:21 +0100
parents a9d6c7e15456
children e7c1019b27b9
line wrap: on
line diff
--- a/Python/import.c	Mon Mar 14 20:46:50 2011 -0400
+++ b/Python/import.c	Mon Mar 07 17:08:21 2011 +0100
@@ -418,7 +418,6 @@
 PyImport_Cleanup(void)
 {
     Py_ssize_t pos, ndone;
-    char *name;
     PyObject *key, *value, *dict;
     PyInterpreterState *interp = PyThreadState_GET()->interp;
     PyObject *modules = interp->modules;
@@ -491,14 +490,13 @@
             if (value->ob_refcnt != 1)
                 continue;
             if (PyUnicode_Check(key) && PyModule_Check(value)) {
-                name = _PyUnicode_AsString(key);
-                if (strcmp(name, "builtins") == 0)
+                if (PyUnicode_CompareWithASCIIString(key, "builtins") == 0)
                     continue;
-                if (strcmp(name, "sys") == 0)
+                if (PyUnicode_CompareWithASCIIString(key, "sys") == 0)
                     continue;
                 if (Py_VerboseFlag)
-                    PySys_WriteStderr(
-                        "# cleanup[1] %s\n", name);
+                    PySys_FormatStderr(
+                        "# cleanup[1] %U\n", key);
                 _PyModule_Clear(value);
                 PyDict_SetItem(modules, key, Py_None);
                 ndone++;
@@ -510,13 +508,12 @@
     pos = 0;
     while (PyDict_Next(modules, &pos, &key, &value)) {
         if (PyUnicode_Check(key) && PyModule_Check(value)) {
-            name = _PyUnicode_AsString(key);
-            if (strcmp(name, "builtins") == 0)
+            if (PyUnicode_CompareWithASCIIString(key, "builtins") == 0)
                 continue;
-            if (strcmp(name, "sys") == 0)
+            if (PyUnicode_CompareWithASCIIString(key, "sys") == 0)
                 continue;
             if (Py_VerboseFlag)
-                PySys_WriteStderr("# cleanup[2] %s\n", name);
+                PySys_FormatStderr("# cleanup[2] %U\n", key);
             _PyModule_Clear(value);
             PyDict_SetItem(modules, key, Py_None);
         }