[Python-checkins] r69016 - in python/branches/release30-maint: Lib/collections.py Lib/doctest.py Misc/NEWS

raymond.hettinger python-checkins at python.org
Tue Jan 27 11:13:46 CET 2009


Author: raymond.hettinger
Date: Tue Jan 27 11:13:45 2009
New Revision: 69016
Log:
Issue 5021: doctest.testfile should set __name__
Modified:
 python/branches/release30-maint/Lib/collections.py
 python/branches/release30-maint/Lib/doctest.py
 python/branches/release30-maint/Misc/NEWS
Modified: python/branches/release30-maint/Lib/collections.py
==============================================================================
--- python/branches/release30-maint/Lib/collections.py	(original)
+++ python/branches/release30-maint/Lib/collections.py	Tue Jan 27 11:13:45 2009
@@ -108,7 +108,7 @@
 # where the named tuple is created. Bypass this step in enviroments where
 # sys._getframe is not defined (Jython for example).
 if hasattr(_sys, '_getframe'):
- result.__module__ = _sys._getframe(1).f_globals['__name__']
+ result.__module__ = _sys._getframe(1).f_globals.get('__name__', '__main__')
 
 return result
 
Modified: python/branches/release30-maint/Lib/doctest.py
==============================================================================
--- python/branches/release30-maint/Lib/doctest.py	(original)
+++ python/branches/release30-maint/Lib/doctest.py	Tue Jan 27 11:13:45 2009
@@ -837,6 +837,8 @@
 globs = globs.copy()
 if extraglobs is not None:
 globs.update(extraglobs)
+ if '__name__' not in globs:
+ globs['__name__'] = '__main__' # provide a default module name
 
 # Recursively expore `obj`, extracting DocTests.
 tests = []
@@ -1947,6 +1949,8 @@
 globs = globs.copy()
 if extraglobs is not None:
 globs.update(extraglobs)
+ if '__name__' not in globs:
+ globs['__name__'] = '__main__'
 
 if raise_on_error:
 runner = DebugRunner(verbose=verbose, optionflags=optionflags)
Modified: python/branches/release30-maint/Misc/NEWS
==============================================================================
--- python/branches/release30-maint/Misc/NEWS	(original)
+++ python/branches/release30-maint/Misc/NEWS	Tue Jan 27 11:13:45 2009
@@ -104,6 +104,9 @@
 operator module; use the abstract base classes instead. Also removed
 the repeat() function; use mul() instead.
 
+- Issue 5021: doctest.testfile() did not create __name__ and
+ collections.namedtuple() relied on __name__ being defined.
+
 - Issue #1885: distutils. When running sdist with --formats=tar,gztar
 the tar file was overriden by the gztar one.
 


More information about the Python-checkins mailing list

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