-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
-W command line options and PYTHONWARNINGS environmental variable should not override -b / -bb command line options #64560
Comments
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 "<string>", line 1, in <module>
BytesWarning: Comparison between bytes and string
$ python3.4 -We -b -c 'print("" == b"")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
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. (Test suite of Python triggers some BytesWarnings, so firstly they will have to be fixed.) |
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). |
Final patch should remove a workaround in Tools/scripts/run_tests.py. |
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. |
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 |
Ok, I merged Nick's PR: -b and -bb options now have the highest priority. I close the issue. |
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: