]> granicus.if.org Git - python/commitdiff
bug [ 839151 ] attempt to access sys.argv when it doesn't exist
authorGeorg Brandl <georg@python.org>
Sun, 26 Jun 2005 22:53:29 +0000 (22:53 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 26 Jun 2005 22:53:29 +0000 (22:53 +0000)
Lib/warnings.py

index 87d3e2947ab6bc6f7f10184e3f6720c6b3c9dd7d..5eac60f7c5b934d8cc634d8945c328d0daf3775f 100644 (file)
@@ -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__", {})