summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-04-13 01:30:58 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-04-13 01:30:58 (GMT)
commit820ae36b8db2dedf281d872264ac82e35fded6e8 (patch)
tree4fe0fb899052d70c5d090bea8e130c8115f4ef5b /Lib/idlelib
parentd16ee63df2fae102b71190162ce34f894b9b2abf (diff)
downloadcpython-820ae36b8db2dedf281d872264ac82e35fded6e8.zip
cpython-820ae36b8db2dedf281d872264ac82e35fded6e8.tar.gz
cpython-820ae36b8db2dedf281d872264ac82e35fded6e8.tar.bz2
Issue 11718: Teach IDLE's open module dialog to find packages.
Diffstat (limited to 'Lib/idlelib')
-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):