[Python-checkins] cpython: Issue #3080: PyImport_Cleanup() uses Unicode
victor.stinner
python-checkins at python.org
Sun Mar 20 04:13:18 CET 2011
http://hg.python.org/cpython/rev/b50a0d44545a
changeset: 68710:b50a0d44545a
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Mon Mar 07 17:08:21 2011 +0100
summary:
Issue #3080: PyImport_Cleanup() uses Unicode
Replace strcmp() by PyUnicode_CompareWithASCIIString()
files:
Python/import.c
diff --git a/Python/import.c b/Python/import.c
--- a/Python/import.c
+++ b/Python/import.c
@@ -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);
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list