From: Raymond Hettinger Date: Wed, 13 Apr 2011 01:54:46 +0000 (-0700) Subject: Issue 11718: Teach IDLE's open module dialog to find packages. X-Git-Tag: v2.7.2rc1~161 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=179816df59744313693d21525046d1d38af9119c;p=python Issue 11718: Teach IDLE's open module dialog to find packages. --- diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index 935a39f6c2..77dcd501e7 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -48,6 +48,21 @@ 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 + base, ext = os.path.splitext(filename) + if ext == '.pyc': + ext = '.py' + filename = base + ext + descr = filename, None, imp.PY_SOURCE return file, filename, descr class EditorWindow(object): diff --git a/Misc/NEWS b/Misc/NEWS index a3d57615fa..4d43f559e9 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -336,6 +336,12 @@ Build - Issue #1099: Fix the build on MacOSX when building a framework with pydebug using GCC 4.0. +IDLE +---- + +- Issue #11718: IDLE's open module dialog couldn't find the __init__.py + file in a package. + Tests -----