]> granicus.if.org Git - python/commitdiff
Issue 11718: Teach IDLE's open module dialog to find packages.
authorRaymond Hettinger <python@rcn.com>
Wed, 13 Apr 2011 01:54:46 +0000 (18:54 -0700)
committerRaymond Hettinger <python@rcn.com>
Wed, 13 Apr 2011 01:54:46 +0000 (18:54 -0700)
Lib/idlelib/EditorWindow.py
Misc/NEWS

index 935a39f6c29da393a9a2b0e115b76e08f5ad710c..77dcd501e718b48efe699f73c19a490e3b88f41d 100644 (file)
@@ -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):
index a3d57615fa5506a0c17eb03b08dfd9724b908e7f..4d43f559e99a75e44f036cd31a0cd5d1931d2f8d 100644 (file)
--- 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
 -----