You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
-W command line options should have higher priority than PYTHONWARNINGS environmental variable #64554
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:
assignee=Noneclosed_at=<Date2014-04-28.22:58:46.484>created_at=<Date2014-01-22.21:41:46.788>labels= ['interpreter-core', 'type-feature']
title='-W command line options should have higher priority than PYTHONWARNINGS environmental variable'updated_at=<Date2014-04-28.22:58:46.482>user='https://bugs.python.org/Arfrever'
About the patch (note the code review tool hasn't accepted it, so I'm commenting here):
in the tests, I think comparing stderr as-is will fail under Windows, where the line separator is b"\r\n"; better call splitlines() first
in the tests, I think it would be better to use test.script_helper.assert_python_ok() (it will automate some stuff for you), even though other tests don't in that file
in main.c, you need to Py_DECREF warning_options when you are done with it.
New changeset 78c0d80a04f9 by Antoine Pitrou in branch 'default':
Issue bpo-20355: -W command line options now have higher priority than the PYTHONWARNINGS environment variable. Patch by Arfrever. http://hg.python.org/cpython/rev/78c0d80a04f9
Activity
Arfrever commentedon Jan 22, 2014
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.)
pitrou commentedon Jan 22, 2014
Agreed.
Arfrever commentedon Jan 23, 2014
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.
pitrou commentedon Jan 23, 2014
Well, 3.4 isn't supposed to receive behaviour changes anymore, unless Larry says it's ok.
pitrou commentedon Jan 23, 2014
About the patch (note the code review tool hasn't accepted it, so I'm commenting here):
larryhastings commentedon Jan 24, 2014
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.
pitrou commentedon Jan 24, 2014
Not really. It's just a bit suboptimal and counter-intuitive
(local settings should trump global settings).
Arfrever commentedon Jan 24, 2014
The new patch includes changes suggested by Antoine. (This patch should be applied after patch from issue bpo-20373.)
brettcannon commentedon Jan 24, 2014
I agree with Antoine; this can wait for Python 3.5.
larryhastings commentedon Jan 24, 2014
Okay, then yes, let's save this for 3.5. Thanks!
serhiy-storchaka commentedon Feb 24, 2014
Final patch should remove a workaround in Tools/scripts/run_tests.py.
python-dev commentedon Apr 28, 2014
New changeset 78c0d80a04f9 by Antoine Pitrou in branch 'default':
Issue bpo-20355: -W command line options now have higher priority than the PYTHONWARNINGS environment variable. Patch by Arfrever.
http://hg.python.org/cpython/rev/78c0d80a04f9
New changeset 925c0b611c02 by Antoine Pitrou in branch 'default':
Remove a workaround for fixed issue bpo-20355.
http://hg.python.org/cpython/rev/925c0b611c02
pitrou commentedon Apr 28, 2014
Committed. Thanks, Arfrever!