summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-03-07 16:08:21 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-03-07 16:08:21 (GMT)
commit9464d61cbab6560e9c8f7278c701cfe47d5287fa (patch)
treef34b47c5f61a417929f4ae5fc1bf683efb8622a3 /Python/import.c
parentf6b563af2d1d8dc1782546436990c0517f226ccf (diff)
downloadcpython-9464d61cbab6560e9c8f7278c701cfe47d5287fa.zip
cpython-9464d61cbab6560e9c8f7278c701cfe47d5287fa.tar.gz
cpython-9464d61cbab6560e9c8f7278c701cfe47d5287fa.tar.bz2
Issue #3080: PyImport_Cleanup() uses Unicode
Replace strcmp() by PyUnicode_CompareWithASCIIString()
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/Python/import.c b/Python/import.c
index b2757df..9366be0 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -418,7 +418,6 @@ void
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 @@ PyImport_Cleanup(void)
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 @@ PyImport_Cleanup(void)
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);
}