summaryrefslogtreecommitdiff
path: root/Lib/idlelib/EditorWindow.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-04-12 18:54:46 -0700
committerRaymond Hettinger <python@rcn.com>2011-04-12 18:54:46 -0700
commit179816df59744313693d21525046d1d38af9119c (patch)
tree18173402a8f2bf274e9a7e3dd31de18970f2bffa /Lib/idlelib/EditorWindow.py
parent0531d6fba5afea68476890db41793cd10ed33f4a (diff)
downloadcpython-git-179816df59744313693d21525046d1d38af9119c.tar.gz
Issue 11718: Teach IDLE's open module dialog to find packages.
Diffstat (limited to 'Lib/idlelib/EditorWindow.py')
-rw-r--r--Lib/idlelib/EditorWindow.py15
1 files changed, 15 insertions, 0 deletions
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):