From f6445e8f4179cbf8825a9d873800c44f9687e229 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 12 Apr 2011 18:30:14 -0700 Subject: Issue 11718: Teach IDLE's open module dialog to find packages. --- Lib/idlelib/EditorWindow.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Lib/idlelib/EditorWindow.py') diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index ffc4e88d9d..3b7bb6df6f 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -50,6 +50,17 @@ def _find_module(fullname, path=None): path = module.__path__ except AttributeError: raise ImportError('No source for module ' + module.__name__) + if descr[2] != imp.PY_SOURCE: + # If all of the above fails and didn't raise an exception,fallback + # to a straight import which can find __init__.py in a package. + m = __import__(fullname) + try: + filename = m.__file__ + except AttributeError: + pass + else: + file = None + descr = os.path.splitext(filename), None, imp.PY_SOURCE return file, filename, descr class EditorWindow(object): -- cgit v1.2.1