diff options
author | Guido van Rossum <guido@python.org> | 2001-08-31 17:46:35 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-08-31 17:46:35 (GMT) |
commit | 8031bbec4a50d98b53815d77e4c5fe8549ab97eb (patch) | |
tree | 499117b5f16bd61bf8136975d45c8a010a9a84e3 | |
parent | 393661d15fa76ec46e9f7b71e97bf2ed38470620 (diff) | |
download | cpython-8031bbec4a50d98b53815d77e4c5fe8549ab97eb.zip cpython-8031bbec4a50d98b53815d77e4c5fe8549ab97eb.tar.gz cpython-8031bbec4a50d98b53815d77e4c5fe8549ab97eb.tar.bz2 |
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.
-rw-r--r-- | Lib/warnings.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py index ea68e4c..5bb00c1 100644 --- 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() |