projects
/
python
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
393661d
)
Allow for the possibility that globals['__name__'] does not exist;
author
Guido van Rossum
<guido@python.org>
Fri, 31 Aug 2001 17:46:35 +0000
(17:46 +0000)
committer
Guido van Rossum
<guido@python.org>
Fri, 31 Aug 2001 17:46:35 +0000
(17:46 +0000)
substitute "<string>" for the module name in that case. This actually
occurred when running test_descr.py with -Dwarn.
Lib/warnings.py
patch
|
blob
|
history
diff --git
a/Lib/warnings.py
b/Lib/warnings.py
index ea68e4c8db2f2bf1c69667896fa495a6ebcacd48..5bb00c19758cf846f9e15fa98dd8c79ea4155b13 100644
(file)
--- a/
Lib/warnings.py
+++ b/
Lib/warnings.py
@@
-24,7
+24,10
@@
def warn(message, category=None, stacklevel=1):
else:
globals = caller.f_globals
lineno = caller.f_lineno
- module = globals['__name__']
+ if globals.has_key('__name__'):
+ module = globals['__name__']
+ else:
+ module = "<string>"
filename = globals.get('__file__')
if filename:
fnl = filename.lower()