Issue 11718: Teach IDLE's open module dialog to find packages.

This commit is contained in:
Raymond Hettinger 2011-04-12 18:54:46 -07:00
parent 0531d6fba5
commit 179816df59
2 changed files with 21 additions and 0 deletions

View File

@ -48,6 +48,21 @@ def _find_module(fullname, path=None):
path = module.__path__ path = module.__path__
except AttributeError: except AttributeError:
raise ImportError, 'No source for module ' + module.__name__ 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 return file, filename, descr
class EditorWindow(object): class EditorWindow(object):

View File

@ -336,6 +336,12 @@ Build
- Issue #1099: Fix the build on MacOSX when building a framework with pydebug - Issue #1099: Fix the build on MacOSX when building a framework with pydebug
using GCC 4.0. using GCC 4.0.
IDLE
----
- Issue #11718: IDLE's open module dialog couldn't find the __init__.py
file in a package.
Tests Tests
----- -----