Issue 28288: Expose environment variable PYTHON_OPT as alternative to command line options (original) (raw)

Created on 2016-09-27 16:24 by Roy Williams, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
pythonenable3kwarningsflag.patch Roy Williams,2016-09-30 16:09 review
pythonenable3kwarningsflag.patch Roy Williams,2016-10-03 20:55 review
pythonenable3kwarningsflag.patch Roy Williams,2016-10-05 00:08 review
Messages (20)
msg277522 - (view) Author: Roy Williams (Roy Williams) * Date: 2016-09-27 16:24
I'm finding the `-3` flag to be super useful, but it's quite a huge pain to thread it through all of the places that spawn python subprocesses, sometimes requiring forking of third party code. This would be much simpler if, like PYTHONWARNINGS, Py_Py3kWarningFlag could be specified as an environment variable.
msg277562 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-09-27 22:40
The idea seems reasonable to me. I would think this would fall under the -3 exemption if others agree this is reasonable to implement.
msg277564 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-09-27 23:26
+1 from me. This would help people to port their projects to Python 3.
msg277579 - (view) Author: Roy Williams (Roy Williams) * Date: 2016-09-28 04:26
@Brett @Berker In a similar vein, it'd be great to expose the `-b` flag in Python 3 in a similar manner to test for invalid byte comparisons.
msg277605 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2016-09-28 10:24
+1, but I'd name the env var PYTHON3WARNINGS. Who knows, when Python 4 comes around the corner, we may need a PYTHON4WARNINGS...
msg277759 - (view) Author: Roy Williams (Roy Williams) * Date: 2016-09-30 16:09
Thanks for your support! Here's a patch to enable the `PYTHON3WARNINGS` environment variable.
msg277790 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-10-01 02:34
Thanks for the patch. I left some comments on Rietveld.
msg278000 - (view) Author: Roy Williams (Roy Williams) * Date: 2016-10-03 20:57
Thanks for the feedback Berker. I addressed your feedback, but unfortunately I get a 500 from Rietveld when I try to attach a new patchset. I've uploaded the new patchset here.
msg278010 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-10-04 05:47
Thanks for the new patch. > I've uploaded the new patchset here. We don't directly upload patches to Rietveld so you did the right thing :) See https://docs.python.org/devguide/patch.html for details. Can you also add a note about this new variable to Doc/howto/pyporting.rst?
msg278095 - (view) Author: Roy Williams (Roy Williams) * Date: 2016-10-05 00:08
Thanks for the feedback Berker! This is my first CPython patch :D. Added in a note in pyporting. I actually did a much more detailed write up here https://gist.github.com/rowillia/c0feed97c1863b2d8e5a3ed73712df65, but it seems a bit verbose for this document.
msg281732 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-11-25 17:13
Roy's patch looks good to me in general. Benjamin, as the RM of 2.7, do you have any objections?
msg281737 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-11-25 20:09
PYTHON3WARNINGS looks as Python 3 variant of PYTHONWARNINGS.
msg281757 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2016-11-26 07:25
Yes, I suppose this falls under the general exemption in 2.x for -3 warning changes. On Fri, Nov 25, 2016, at 09:13, Berker Peksag wrote: > > Berker Peksag added the comment: > > Roy's patch looks good to me in general. Benjamin, as the RM of 2.7, do > you have any objections? > > ---------- > nosy: +benjamin.peterson > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue28288> > _______________________________________
msg281890 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-11-28 17:00
> PYTHON3WARNINGS looks as Python 3 variant of PYTHONWARNINGS. Sadly, I can't think of a better name. Do you have a suggestion? > Yes, I suppose this falls under the general exemption in 2.x for -3 warning changes. Thanks, Benjamin!
msg281898 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-11-28 17:21
What about PYTHON_OPT and allowing to pass any options via an environment variable? There is a number of precedences (gzip, less, etc). export PYTHON_OPT="-t -b -3" Or PYTHON3COMP[ATIBILITY]?
msg281900 - (view) Author: Roy Williams (Roy Williams) * Date: 2016-11-28 17:35
> What about PYTHON_OPT and allowing to pass any options via an environment > > variable? There is a number of precedences (gzip, less, etc). > > export PYTHON_OPT="-t -b -3" I'd be open to this, but it seems like a much wider change than something that I'd have time to build in time for Python 2.7.12. I agree that this is a better long term direction (similarly, I'd like to enable the `-bb` flag in Python 3). I'd have to put a bunch of thought into how this would merge with command line flags. > Or PYTHON3COMP[ATIBILITY]? I'm open to whichever. lemburg had suggested `PYTHON3WARNINGS` so that's what I went with. If that's a blocker for this patch happy to change it.
msg281903 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-11-28 18:09
I agree with Roy: while PYTHON_OPT might be nice long-term, I think that scopes it beyond a py3k change in Python 2.7 and into new feature territory. As for a better name, PY3KWARNINGS is also possible and minimizes typo issues if that's what people are worried about.
msg281904 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-11-28 18:17
Benjamin just announced 2.7.13rc1 is going to be Dec 3, so this patch needs to land before then if it's going to make it in the next release.
msg281905 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-11-28 18:31
I can commit the patch this week if there are no objections to the name of the variable. I like Brett's PY3KWARNINGS suggestion, but I'm fine with either of the suggested names.
msg382162 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-11-30 16:54
It's too late for the PYTHON3WARNINGS variable in 2.7, but Serhiy's suggestion for PYTHON_OPTS can still be implemented. Updating title and version accordingly.
History
Date User Action Args
2022-04-11 14:58:37 admin set github: 72475
2020-11-30 16:54:41 iritkatriel set nosy: + iritkatrieltitle: Expose environment variable for Py_Py3kWarningFlag -> Expose environment variable PYTHON_OPT as alternative to command line optionsmessages: + versions: + Python 3.10, - Python 2.7
2016-11-28 18:31:46 berker.peksag set messages: +
2016-11-28 18:17:30 brett.cannon set messages: +
2016-11-28 18:09:40 brett.cannon set messages: +
2016-11-28 17:35:03 Roy Williams set messages: +
2016-11-28 17:21:16 serhiy.storchaka set messages: +
2016-11-28 17:00:23 berker.peksag set messages: +
2016-11-26 07:25:20 benjamin.peterson set messages: +
2016-11-25 20:09:28 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2016-11-25 17:13:14 berker.peksag set nosy: + benjamin.petersonmessages: +
2016-10-05 00:08:14 Roy Williams set files: + pythonenable3kwarningsflag.patchmessages: +
2016-10-04 05:47:45 berker.peksag set messages: +
2016-10-03 20:57:14 Roy Williams set messages: +
2016-10-03 20:55:56 Roy Williams set files: + pythonenable3kwarningsflag.patch
2016-10-01 02:34:27 berker.peksag set messages: + stage: test needed -> patch review
2016-09-30 16:09:30 Roy Williams set files: + pythonenable3kwarningsflag.patchkeywords: + patchmessages: +
2016-09-28 10:24:29 lemburg set nosy: + lemburgmessages: +
2016-09-28 04:26:40 Roy Williams set messages: +
2016-09-27 23:26:38 berker.peksag set nosy: + berker.peksagmessages: +
2016-09-27 22:40:51 brett.cannon set nosy: + brett.cannonmessages: +
2016-09-27 22:40:01 brett.cannon set type: behavior -> enhancement
2016-09-27 22:39:48 brett.cannon set stage: test needed
2016-09-27 22:39:40 brett.cannon set components: + Interpreter Core, - 2to3 (2.x to 3.x conversion tool)
2016-09-27 16:24:06 Roy Williams create