From: <bc...@wo...> - 2000-12-19 13:34:17
|
>Bug #126327, was updated on 2000-Dec-19 05:28 >Here is a current snapshot of the bug. >Summary: Infinite recursion in subpackage import >http://sourceforge.net/bugs/?func=detailbug&bug_id=126327&group_id=12867 Here a possible patch. Since the CVS notification is out, and I'm unsure whether this is right solution, I post it here. Basicly the patch checks the sys.module for each level when walking down a dotted path. --- imp.java.org Mon Dec 18 20:18:43 2000 +++ imp.java Tue Dec 19 13:57:52 2000 @@ -400,6 +400,8 @@ private static PyObject dottedFind(PyObject mod, String name) { int dot = 0; int last_dot= 0; + PyObject modules = Py.getSystemState().modules; + do { String tmpName; dot = name.indexOf('.', last_dot); @@ -408,9 +410,19 @@ } else { tmpName = name.substring(last_dot, dot).intern(); } - mod = mod.__findattr__(tmpName); - if (mod == null) - throw Py.ImportError("No module named " + tmpName); + PyObject m = null; + PyObject modname = mod.__findattr__("__name__"); + if (name != null) { + String fullname = modname + "." + tmpName; + m = modules.__finditem__(fullname.intern()); + } + if (m != null && m != Py.None) { + mod = m; + } else { + mod = mod.__findattr__(tmpName); + if (mod == null) + throw Py.ImportError("No module named " + tmpName); + } last_dot = dot + 1; } while (dot != -1); return mod; |