This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Created on 2019-12-15 18:43 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17618 merged serhiy.storchaka, 2019-12-15 19:07
PR 17831 merged miss-islington, 2020-01-05 12:15
PR 17832 merged miss-islington, 2020-01-05 12:15
Messages (4)
msg358439 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-12-15 18:43
There are some issues with handling the -W option: 1. A traceback is printed for some invalid category names. $ ./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' 2. For non-ascii warning names Python complains about a module and strips the last character: $ ./python -Wignore::Wärning Invalid -W option ignored: invalid module name: 'Wärnin' 3. The re module is always imported is the -W option is used, even if this is not needed.
msg359333 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-01-05 12:15
 New changeset 41ec17e45d54473d32f543396293256f1581e44d by Serhiy Storchaka in branch 'master': bpo-39056: Fix handling invalid warning category in the -W option. (GH-17618) https://github.com/python/cpython/commit/41ec17e45d54473d32f543396293256f1581e44d 
msg359338 - (view) Author: miss-islington (miss-islington) Date: 2020-01-05 12:33
 New changeset e1caa49f68dd63b534774aebad0c240143e6fb5d by Miss Islington (bot) in branch '3.8': bpo-39056: Fix handling invalid warning category in the -W option. (GH-17618) https://github.com/python/cpython/commit/e1caa49f68dd63b534774aebad0c240143e6fb5d 
msg359339 - (view) Author: miss-islington (miss-islington) Date: 2020-01-05 12:35
 New changeset 43fbc70360b2a934ea809b2175d7e99031db2df3 by Miss Islington (bot) in branch '3.7': bpo-39056: Fix handling invalid warning category in the -W option. (GH-17618) https://github.com/python/cpython/commit/43fbc70360b2a934ea809b2175d7e99031db2df3 
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83237
2020-01-05 13:33:25serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-01-05 12:35:02miss-islingtonsetmessages: + msg359339
2020-01-05 12:33:11miss-islingtonsetnosy: + miss-islington
messages: + msg359338
2020-01-05 12:15:45miss-islingtonsetpull_requests: + pull_request17259
2020-01-05 12:15:38miss-islingtonsetpull_requests: + pull_request17258
2020-01-05 12:15:30serhiy.storchakasetmessages: + msg359333
2019-12-15 19:07:06serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request17088
2019-12-15 18:43:33serhiy.storchakacreate