msg208894 - (view) |
Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) *  |
Date: 2014-01-23 09:19 |
Currently -W command line options and PYTHONWARNINGS environmental variable non-intuitively override settings specified by -b / -bb command line options. $ python3.4 -c 'print("" == b"")' False $ python3.4 -b -c 'print("" == b"")' -c:1: BytesWarning: Comparison between bytes and string False $ python3.4 -bb -c 'print("" == b"")' Traceback (most recent call last): File "", line 1, in BytesWarning: Comparison between bytes and string $ python3.4 -We -b -c 'print("" == b"")' Traceback (most recent call last): File "", line 1, in BytesWarning: Comparison between bytes and string $ python3.4 -Wd -bb -c 'print("" == b"")' -c:1: BytesWarning: Comparison between bytes and string False $ python3.4 -Wi -b -c 'print("" == b"")' False $ python3.4 -Wi -bb -c 'print("" == b"")' False $ I suggest to increase priority of -b / -bb command line options. The attached patch should be applied after patch from issue #20355. (Test suite of Python triggers some BytesWarnings, so firstly they will have to be fixed.) |
|
|
msg208898 - (view) |
Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) *  |
Date: 2014-01-23 09:34 |
By the way, Tools/scripts/run_tests.py (used by 'test' target in Makefile) passes '-W default -bb', which currently fails work as intended (i.e. treating BytesWarnings as errors). |
|
|
msg212095 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2014-02-24 13:33 |
Final patch should remove a workaround in Tools/scripts/run_tests.py. |
|
|
msg217439 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2014-04-28 22:59 |
The patch is a bit problematic, because Py_BytesWarningFlag may also be set by e.g. an application embedding Python, but then Python's main.c won't be executed. |
|
|
msg307792 - (view) |
Author: Alyssa Coghlan (ncoghlan) *  |
Date: 2017-12-07 07:37 |
The approach I've taken in my PR is similar to the one that Arfrever proposed (albeit different in the details due to other changes in the startup code since that patch was written). For the embedding case, I've simply noted in the What's New section of the porting guide that embedding applications need to configure a `error::BytesWarning` filter explicitly if they want to treat BytesWarning as errors (in addition to setting the flag to request that the warnings be emitted in the first place). |
|
|
msg308157 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2017-12-12 21:59 |
New changeset 747f48e2e92390c44c72f52a1239959601cde157 by Victor Stinner in branch 'master': bpo-32230: Set sys.warnoptions with -X dev (#4820) https://github.com/python/cpython/commit/747f48e2e92390c44c72f52a1239959601cde157 |
|
|
msg308158 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2017-12-12 22:01 |
Ok, I merged Nick's PR: -b and -bb options now have the highest priority. I close the issue. |
|
|
msg310500 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2018-01-23 12:30 |
New changeset dc6b9462c00873c8404a7966b7ca210717718af5 by Victor Stinner in branch 'master': bpo-20361: Remove workaround for a now fixed bug (#5283) https://github.com/python/cpython/commit/dc6b9462c00873c8404a7966b7ca210717718af5 |
|
|