mirror of https://github.com/python/cpython
bug [ 839151 ] attempt to access sys.argv when it doesn't exist
This commit is contained in:
parent
1f149642c9
commit
12fe9b4ce4
|
@ -50,7 +50,11 @@ def warn(message, category=None, stacklevel=1):
|
|||
filename = filename[:-1]
|
||||
else:
|
||||
if module == "__main__":
|
||||
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…
Reference in New Issue