mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Allow for the possibility that globals['__name__'] does not exist;
substitute "<string>" for the module name in that case. This actually occurred when running test_descr.py with -Dwarn.
This commit is contained in:
parent
393661d15f
commit
8031bbec4a
1 changed files with 4 additions and 1 deletions
|
@ -24,7 +24,10 @@ def warn(message, category=None, stacklevel=1):
|
||||||
else:
|
else:
|
||||||
globals = caller.f_globals
|
globals = caller.f_globals
|
||||||
lineno = caller.f_lineno
|
lineno = caller.f_lineno
|
||||||
|
if globals.has_key('__name__'):
|
||||||
module = globals['__name__']
|
module = globals['__name__']
|
||||||
|
else:
|
||||||
|
module = "<string>"
|
||||||
filename = globals.get('__file__')
|
filename = globals.get('__file__')
|
||||||
if filename:
|
if filename:
|
||||||
fnl = filename.lower()
|
fnl = filename.lower()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue