mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bug [ 839151 ] attempt to access sys.argv when it doesn't exist
This commit is contained in:
parent
1f149642c9
commit
12fe9b4ce4
1 changed files with 5 additions and 1 deletions
|
@ -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__", {})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue