Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8c0cee81
Commit
8c0cee81
authored
Jan 27, 2009
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 5021: doctest.testfile should set __name__
parent
cdc9f2c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
1 deletion
+8
-1
Lib/collections.py
Lib/collections.py
+1
-1
Lib/doctest.py
Lib/doctest.py
+4
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/collections.py
View file @
8c0cee81
...
@@ -103,7 +103,7 @@ def namedtuple(typename, field_names, verbose=False):
...
@@ -103,7 +103,7 @@ def namedtuple(typename, field_names, verbose=False):
# where the named tuple is created. Bypass this step in enviroments where
# where the named tuple is created. Bypass this step in enviroments where
# sys._getframe is not defined (Jython for example).
# sys._getframe is not defined (Jython for example).
if
hasattr
(
_sys
,
'_getframe'
):
if
hasattr
(
_sys
,
'_getframe'
):
result
.
__module__
=
_sys
.
_getframe
(
1
).
f_globals
[
'__name__'
]
result
.
__module__
=
_sys
.
_getframe
(
1
).
f_globals
.
get
(
'__name__'
,
'__main__'
)
return
result
return
result
...
...
Lib/doctest.py
View file @
8c0cee81
...
@@ -844,6 +844,8 @@ class DocTestFinder:
...
@@ -844,6 +844,8 @@ class DocTestFinder:
globs = globs.copy()
globs = globs.copy()
if extraglobs is not None:
if extraglobs is not None:
globs.update(extraglobs)
globs.update(extraglobs)
if '__name__' not in globs:
globs['__name__'] = '__main__' # provide a default module name
# Recursively expore `obj`, extracting DocTests.
# Recursively expore `obj`, extracting DocTests.
tests = []
tests = []
...
@@ -1937,6 +1939,8 @@ def testfile(filename, module_relative=True, name=None, package=None,
...
@@ -1937,6 +1939,8 @@ def testfile(filename, module_relative=True, name=None, package=None,
globs
=
globs
.
copy
()
globs
=
globs
.
copy
()
if
extraglobs
is
not
None
:
if
extraglobs
is
not
None
:
globs
.
update
(
extraglobs
)
globs
.
update
(
extraglobs
)
if
'__name__'
not
in
globs
:
globs
[
'__name__'
]
=
'__main__'
if
raise_on_error
:
if
raise_on_error
:
runner
=
DebugRunner
(
verbose
=
verbose
,
optionflags
=
optionflags
)
runner
=
DebugRunner
(
verbose
=
verbose
,
optionflags
=
optionflags
)
...
...
Misc/NEWS
View file @
8c0cee81
...
@@ -76,6 +76,9 @@ Core and Builtins
...
@@ -76,6 +76,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue 5021: doctest.testfile() did not create __name__ and
collections.namedtuple() relied on __name__ being defined.
- Issue #3881: Help Tcl to load even when started through the
- Issue #3881: Help Tcl to load even when started through the
unreadable local symlink to "Program Files" on Vista.
unreadable local symlink to "Program Files" on Vista.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment