[Python-checkins] cpython (2.7): Issue 11718: Teach IDLE's open module dialog to find packages.

raymond.hettinger python-checkins at python.org
Wed Apr 13 03:54:59 CEST 2011


http://hg.python.org/cpython/rev/e391f7005b0f
changeset:   69310:e391f7005b0f
branch:      2.7
user:        Raymond Hettinger <python at rcn.com>
date:        Tue Apr 12 18:54:46 2011 -0700
summary:
  Issue 11718: Teach IDLE's open module dialog to find packages.

files:
  Lib/idlelib/EditorWindow.py |  15 +++++++++++++++
  Misc/NEWS                   |   6 ++++++
  2 files changed, 21 insertions(+), 0 deletions(-)


diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -48,6 +48,21 @@
             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):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -336,6 +336,12 @@
 - 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
 -----
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list