-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
-W command line options should have higher priority than PYTHONWARNINGS environmental variable #64554
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
Comments
Currently Python has non-intuitive behavior such that PYTHONWARNINGS environmental variable has higher priority than -W command line options. $ python3.4 -c '__import__("warnings").warn("xxx", DeprecationWarning)'
$ python3.4 -Wd -c '__import__("warnings").warn("xxx", DeprecationWarning)'
-c:1: DeprecationWarning: xxx
$ python3.4 -We -c '__import__("warnings").warn("xxx", DeprecationWarning)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
DeprecationWarning: xxx
$ PYTHONWARNINGS="e" python3.4 -Wd -c '__import__("warnings").warn("xxx", DeprecationWarning)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
DeprecationWarning: xxx
$ PYTHONWARNINGS="d" python3.4 -We -c '__import__("warnings").warn("xxx", DeprecationWarning)'
-c:1: DeprecationWarning: xxx
$ I think that settings from -W command line options should have higher priority than PYTHONWARNINGS environmental variable. (Adding people from issue bpo-7301 to nosy list.) |
Agreed. |
The attached patch moves calls to PySys_AddWarnOption* for -W options to after parsing PYTHONWARNINGS. I think that this bug fix could be applied in Python 3.4. The patch does not introduce any failures in full test suite. |
Well, 3.4 isn't supposed to receive behaviour changes anymore, unless Larry says it's ok. |
About the patch (note the code review tool hasn't accepted it, so I'm commenting here):
|
Is this behavior causing problems? How bad is it? Can I get more opinions about this than just Arfrever and Antoine? Not that I don't trust their opinions, I just want to see a larger sample size. |
Not really. It's just a bit suboptimal and counter-intuitive |
The new patch includes changes suggested by Antoine. (This patch should be applied after patch from issue bpo-20373.) |
I agree with Antoine; this can wait for Python 3.5. |
Okay, then yes, let's save this for 3.5. Thanks! |
Final patch should remove a workaround in Tools/scripts/run_tests.py. |
New changeset 78c0d80a04f9 by Antoine Pitrou in branch 'default': New changeset 925c0b611c02 by Antoine Pitrou in branch 'default': |
Committed. Thanks, Arfrever! |
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: