This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Expose environment variable PYTHON_OPT as alternative to command line options
Type: enhancement Stage: patch review
Components: Interpreter Core Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Roy Williams, benjamin.peterson, berker.peksag, brett.cannon, iritkatriel, lemburg, serhiy.storchaka
Priority: normal Keywords: patch

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:37adminsetgithub: 72475
2020-11-30 16:54:41iritkatrielsetnosy: + iritkatriel
title: Expose environment variable for Py_Py3kWarningFlag -> Expose environment variable PYTHON_OPT as alternative to command line options
messages: + msg382162

versions: + Python 3.10, - Python 2.7
2016-11-28 18:31:46berker.peksagsetmessages: + msg281905
2016-11-28 18:17:30brett.cannonsetmessages: + msg281904
2016-11-28 18:09:40brett.cannonsetmessages: + msg281903
2016-11-28 17:35:03Roy Williamssetmessages: + msg281900
2016-11-28 17:21:16serhiy.storchakasetmessages: + msg281898
2016-11-28 17:00:23berker.peksagsetmessages: + msg281890
2016-11-26 07:25:20benjamin.petersonsetmessages: + msg281757
2016-11-25 20:09:28serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg281737
2016-11-25 17:13:14berker.peksagsetnosy: + benjamin.peterson
messages: + msg281732
2016-10-05 00:08:14Roy Williamssetfiles: + pythonenable3kwarningsflag.patch

messages: + msg278095
2016-10-04 05:47:45berker.peksagsetmessages: + msg278010
2016-10-03 20:57:14Roy Williamssetmessages: + msg278000
2016-10-03 20:55:56Roy Williamssetfiles: + pythonenable3kwarningsflag.patch
2016-10-01 02:34:27berker.peksagsetmessages: + msg277790
stage: test needed -> patch review
2016-09-30 16:09:30Roy Williamssetfiles: + pythonenable3kwarningsflag.patch
keywords: + patch
messages: + msg277759
2016-09-28 10:24:29lemburgsetnosy: + lemburg
messages: + msg277605
2016-09-28 04:26:40Roy Williamssetmessages: + msg277579
2016-09-27 23:26:38berker.peksagsetnosy: + berker.peksag
messages: + msg277564
2016-09-27 22:40:51brett.cannonsetnosy: + brett.cannon
messages: + msg277562
2016-09-27 22:40:01brett.cannonsettype: behavior -> enhancement
2016-09-27 22:39:48brett.cannonsetstage: test needed
2016-09-27 22:39:40brett.cannonsetcomponents: + Interpreter Core, - 2to3 (2.x to 3.x conversion tool)
2016-09-27 16:24:06Roy Williamscreate