-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with handling the -W option #83237
Comments
There are some issues with handling the -W option:
$ ./python -Wignore::0
'import warnings' failed; traceback:
Traceback (most recent call last):
File "/home/serhiy/py/cpython/Lib/warnings.py", line 542, in <module>
_processoptions(sys.warnoptions)
File "/home/serhiy/py/cpython/Lib/warnings.py", line 208, in _processoptions
_setoption(arg)
File "/home/serhiy/py/cpython/Lib/warnings.py", line 224, in _setoption
category = _getcategory(category)
File "/home/serhiy/py/cpython/Lib/warnings.py", line 271, in _getcategory
if not issubclass(cat, Warning):
TypeError: issubclass() arg 1 must be a class
$ ./python -Wignore::0a
'import warnings' failed; traceback:
Traceback (most recent call last):
File "/home/serhiy/py/cpython/Lib/warnings.py", line 542, in <module>
_processoptions(sys.warnoptions)
File "/home/serhiy/py/cpython/Lib/warnings.py", line 208, in _processoptions
_setoption(arg)
File "/home/serhiy/py/cpython/Lib/warnings.py", line 224, in _setoption
category = _getcategory(category)
File "/home/serhiy/py/cpython/Lib/warnings.py", line 256, in _getcategory
cat = eval(category)
File "<string>", line 1
0a
^
SyntaxError: unexpected EOF while parsing
$ ./python -Wignore::=
'import warnings' failed; traceback:
Traceback (most recent call last):
File "/home/serhiy/py/cpython/Lib/warnings.py", line 542, in <module>
_processoptions(sys.warnoptions)
File "/home/serhiy/py/cpython/Lib/warnings.py", line 208, in _processoptions
_setoption(arg)
File "/home/serhiy/py/cpython/Lib/warnings.py", line 224, in _setoption
category = _getcategory(category)
File "/home/serhiy/py/cpython/Lib/warnings.py", line 264, in _getcategory
m = __import__(module, None, None, [klass])
ValueError: Empty module name In normal case Python just complains: $ ./python -Wignore::unknown
Invalid -W option ignored: unknown warning category: 'unknown'
$ ./python -Wignore::Wärning
Invalid -W option ignored: invalid module name: 'Wärnin'
|
serhiy-storchaka
added
3.7 (EOL)
end of life
3.8
only security fixes
3.9
only security fixes
stdlib
Python modules in the Lib dir
type-bug
An unexpected behavior, bug, or error
labels
Dec 15, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: