[Python-checkins] r67047 - in python/branches/release26-maint: Lib/modulefinder.py Lib/test/test_modulefinder.py Misc/NEWS

thomas.heller python-checkins at python.org
Fri Oct 31 00:47:26 CET 2008


Author: thomas.heller
Date: Thu Oct 30 21:29:54 2008
New Revision: 67047
Log:
Merged revisions 67046 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk
........
 r67046 | thomas.heller | 2008年10月30日 21:18:13 +0100 (Do, 30 Okt 2008) | 2 lines
 
 Fixed a modulefinder crash on certain relative imports.
........
Modified:
 python/branches/release26-maint/ (props changed)
 python/branches/release26-maint/Lib/modulefinder.py
 python/branches/release26-maint/Lib/test/test_modulefinder.py
 python/branches/release26-maint/Misc/NEWS
Modified: python/branches/release26-maint/Lib/modulefinder.py
==============================================================================
--- python/branches/release26-maint/Lib/modulefinder.py	(original)
+++ python/branches/release26-maint/Lib/modulefinder.py	Thu Oct 30 21:29:54 2008
@@ -309,7 +309,10 @@
 def _add_badmodule(self, name, caller):
 if name not in self.badmodules:
 self.badmodules[name] = {}
- self.badmodules[name][caller.__name__] = 1
+ if caller:
+ self.badmodules[name][caller.__name__] = 1
+ else:
+ self.badmodules[name]["-"] = 1
 
 def _safe_import_hook(self, name, caller, fromlist, level=-1):
 # wrapper for self.import_hook() that won't raise ImportError
Modified: python/branches/release26-maint/Lib/test/test_modulefinder.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_modulefinder.py	(original)
+++ python/branches/release26-maint/Lib/test/test_modulefinder.py	Thu Oct 30 21:29:54 2008
@@ -190,6 +190,19 @@
 a/b/c/f.py
 """]
 
+relative_import_test_3 = [
+ "a.module",
+ ["a", "a.module"],
+ ["a.bar"],
+ [],
+ """\
+a/__init__.py
+ def foo(): pass
+a/module.py
+ from . import foo
+ from . import bar
+"""]
+
 def open_file(path):
 ##print "#", os.path.abspath(path)
 dirname = os.path.dirname(path)
@@ -256,6 +269,9 @@
 def test_relative_imports_2(self):
 self._do_test(relative_import_test_2)
 
+ def test_relative_imports_3(self):
+ self._do_test(relative_import_test_3)
+
 def test_main():
 distutils.log.set_threshold(distutils.log.WARN)
 test_support.run_unittest(ModuleFinderTest)
Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS	(original)
+++ python/branches/release26-maint/Misc/NEWS	Thu Oct 30 21:29:54 2008
@@ -30,6 +30,8 @@
 Library
 -------
 
+- Fixed a modulefinder crash on certain relative imports.
+
 - Issue #4150: Pdb's "up" command now works for generator frames in post-mortem
 debugging.
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /