summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/EditorWindow.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-04-13 01:30:14 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-04-13 01:30:14 (GMT)
commitf6445e8f4179cbf8825a9d873800c44f9687e229 (patch)
tree8389a3eb79638db0f6d4fd63ff44aa8e158b31ae /Lib/idlelib/EditorWindow.py
parentd5315482e92d1f3c47460999a790df684bf8b09e (diff)
downloadcpython-f6445e8f4179cbf8825a9d873800c44f9687e229.zip
cpython-f6445e8f4179cbf8825a9d873800c44f9687e229.tar.gz
cpython-f6445e8f4179cbf8825a9d873800c44f9687e229.tar.bz2
Issue 11718: Teach IDLE's open module dialog to find packages.
Diffstat (limited to 'Lib/idlelib/EditorWindow.py')
-rw-r--r--Lib/idlelib/EditorWindow.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index ffc4e88..3b7bb6d 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):