summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2005-06-26 22:53:29 (GMT)
committerGeorg Brandl <georg@python.org>2005-06-26 22:53:29 (GMT)
commit12fe9b4ce492a676d77640a9caf8fc9a26cc5d53 (patch)
tree9ce40c214d35a651ba44222875b9c4049e6b4a12
parent1f149642c9940662f45004a0bf5f5b05034aa67b (diff)
downloadcpython-12fe9b4ce492a676d77640a9caf8fc9a26cc5d53.zip
cpython-12fe9b4ce492a676d77640a9caf8fc9a26cc5d53.tar.gz
cpython-12fe9b4ce492a676d77640a9caf8fc9a26cc5d53.tar.bz2
bug [ 839151 ] attempt to access sys.argv when it doesn't exist
-rw-r--r--Lib/warnings.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py
index 87d3e29..5eac60f 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -50,7 +50,11 @@ def warn(message, category=None, stacklevel=1):
filename = filename[:-1]
else:
if module == "__main__":
- filename = sys.argv[0]
+ try:
+ filename = sys.argv[0]
+ except AttributeError:
+ # embedded interpreters don't have sys.argv, see bug #839151
+ filename = '__main__'
if not filename:
filename = module
registry = globals.setdefault("__warningregistry__", {})