New submission from Paul Pogonyshev:
This is apparently because sys.modules contains Unicode (str) keys,
while 'parentname' is an old-style string. Attached patch seems to fix
it, but I have no idea if it is correct in principle
----------
components: Interpreter Core
files: reloading-fix.diff
messages: 57085
nosy: Paul Pogonyshev
severity: normal
status: open
title: reloading imported modules sometimes fail with 'parent not in
sys.modules' error
versions: Python 3.0
Added file: http://bugs.python.org/file8683/reloading-fix.diff
__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1379>
__________________________________
Index: import.c
===================================================================
--- import.c (revision 58800)
+++ import.c (working copy)
@@ -2384,7 +2384,7 @@
subname = name;
else {
PyObject *parentname, *parent;
- parentname = PyString_FromStringAndSize(name, (subname-name));
+ parentname = PyUnicode_FromStringAndSize(name, (subname-name));
if (parentname == NULL) {
imp_modules_reloading_clear();
return NULL;
@@ -2393,7 +2393,7 @@
if (parent == NULL) {
PyErr_Format(PyExc_ImportError,
"reload(): parent %.200s not in sys.modules",
- PyString_AS_STRING(parentname));
+ PyUnicode_AsUTF32String(parentname));
Py_DECREF(parentname);
imp_modules_reloading_clear();
return NULL;
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com