classification
Title: Display DeprecationWarning, PendingDeprecationWarning and ImportWarning in debug mode
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, lukasz.langa, vstinner
Priority: normal Keywords: patch

Created on 2017-11-20 14:26 by vstinner, last changed 2017-11-20 17:48 by lukasz.langa. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4474 merged vstinner, 2017-11-20 14:52
Messages (4)
msg306547 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-20 14:26
Related python-dev thread:
https://mail.python.org/pipermail/python-dev/2017-November/150608.html
"[Python-Dev] Show DeprecationWarning in debug mode?"

I propose to display Display DeprecationWarning, PendingDeprecationWarning and ImportWarning when Python is compiled in debug mode.

Attached PR implements proposed change.
msg306549 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-20 15:00
Warnings filters in debug mode.

Reference (current code):

$ ./python -c 'import warnings, pprint; pprint.pprint(warnings.filters)'
[('ignore', None, <class 'DeprecationWarning'>, None, 0),
 ('ignore', None, <class 'PendingDeprecationWarning'>, None, 0),
 ('ignore', None, <class 'ImportWarning'>, None, 0),
 ('ignore', None, <class 'BytesWarning'>, None, 0),
 ('always', None, <class 'ResourceWarning'>, None, 0)]

With my PR 4474:

$ ./python -c 'import warnings, pprint; pprint.pprint(warnings.filters)'
[('ignore', None, <class 'BytesWarning'>, None, 0),
 ('always', None, <class 'ResourceWarning'>, None, 0)]


BytesWarning is not modified by my PR since this specific warning is controlled by the -b option. Example with my PR.

-b option, ignore => default:

$ ./python -b -c 'import warnings, pprint; pprint.pprint(warnings.filters)'
[('default', None, <class 'BytesWarning'>, None, 0),
 ('always', None, <class 'ResourceWarning'>, None, 0)]

-bb option, ignore => error:

$ ./python -bb -c 'import warnings, pprint; pprint.pprint(warnings.filters)'
[('error', None, <class 'BytesWarning'>, None, 0),
 ('always', None, <class 'ResourceWarning'>, None, 0)]


Note: While writing this comment, I also found a bug in the new developer mode (-X dev): bpo-32089.
msg306571 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2017-11-20 17:47
New changeset 895862aa01793a26e74512befb0c66a1da2587d6 by Łukasz Langa (Victor Stinner) in branch 'master':
bpo-32088: Display Deprecation in debug mode (#4474)
https://github.com/python/cpython/commit/895862aa01793a26e74512befb0c66a1da2587d6
msg306572 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2017-11-20 17:48
Merged. This is an important improvement to make sure 3.7's quality is the best possible.

Thanks! ✨ 🍰 ✨
History
Date User Action Args
2017-11-20 17:48:41lukasz.langasetstatus: open -> closed
resolution: fixed
messages: + msg306572

stage: patch review -> resolved
2017-11-20 17:47:06lukasz.langasetnosy: + lukasz.langa
messages: + msg306571
2017-11-20 15:00:44vstinnersetmessages: + msg306549
2017-11-20 14:52:07vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request4409
2017-11-20 14:52:04barrysetnosy: + barry
2017-11-20 14:26:42vstinnercreate