From 12fe9b4ce492a676d77640a9caf8fc9a26cc5d53 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 26 Jun 2005 22:53:29 +0000 Subject: bug [ 839151 ] attempt to access sys.argv when it doesn't exist --- Lib/warnings.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Lib/warnings.py') 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__", {}) -- cgit v1.2.1