summaryrefslogtreecommitdiff
path: root/Lib/warnings.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2005-06-26 22:53:29 +0000
committerGeorg Brandl <georg@python.org>2005-06-26 22:53:29 +0000
commit12fe9b4ce492a676d77640a9caf8fc9a26cc5d53 (patch)
tree9ce40c214d35a651ba44222875b9c4049e6b4a12 /Lib/warnings.py
parent1f149642c9940662f45004a0bf5f5b05034aa67b (diff)
downloadcpython-git-12fe9b4ce492a676d77640a9caf8fc9a26cc5d53.tar.gz
bug [ 839151 ] attempt to access sys.argv when it doesn't exist
Diffstat (limited to 'Lib/warnings.py')
-rw-r--r--Lib/warnings.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py
index 87d3e2947a..5eac60f7c5 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__", {})