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: Add PYTHONDEVMODE=1 to enable the developer mode
Type: enhancement Stage: resolved
Components: Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ncoghlan, pitrou, vstinner
Priority: normal Keywords: patch

Created on 2017-11-21 02:58 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4478 vstinner, 2017-11-21 02:59
PR 4624 merged vstinner, 2017-11-29 00:07
PR 4821 merged vstinner, 2017-12-12 21:55
Messages (6)
msg306618 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-21 02:58
In the review of the PR 4478, Antoine Pitrou proposed to add an environment variable to enable the new Python "developer mode" to inherit the developer mode in child Python processes.

I proposed to add PYTHONDEVMODE=1. Nick Coghlan proposed PYTHONXOPTIONS=dev.

While -X is a new "catch all" for new CPython options, Python got new PYTHONxxx environment variables to enable new options:

* -X faulthandler: PYTHONFAULTHANDLER=1
* -X tracemalloc=N: PYTHONTRACEMALLOC=n
* -X importtime: PYTHONPROFILEIMPORTTIME=1 -- note that the names are different in this case, I don't know why

I have a preference for PYTHONDEVMODE=1.

If we start to use PYTHONXOPTIONS, users may want to use PYTHONXOPTIONS=tracemalloc, and then we have to decide which environment variable has the preference :-(

Moreover, tracemalloc takes an argument, whereas environment variables with a value containing '=' are rare and so likely to cause issues in programs not carefully written to handle such variables. (Environment variables are inherited by all processes, not only Python processes.)
msg306625 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2017-11-21 03:48
Another argument against PYTHONXOPTIONS is that each implementation is free to decide which -X options it wants to support, and we don't really define what they're supposed to do with options they don't recognise.

By contrast, there's an established behaviour for unknown environment variables: implementations that don't support them just ignore them.

So +1 for PYTHONDEVMODE=1 from me - that also gives us more flexibility if we decide to add arguments to the option later.
msg307195 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-29 00:09
While implementing a new PYTHONDEVMODE environment variable, I found that it would help to also add a new sys.flags.dev_mode flag. So I added it.

So for example, asyncio uses sys.flags.dev_mode rather than checking for 'dev' in sys._xoptions *and* check if the environment variable is set or not.
msg307284 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-30 10:40
New changeset 5e3806f8cfd84722fc55d4299dc018ad9b0f8401 by Victor Stinner in branch 'master':
bpo-32101: Add PYTHONDEVMODE environment variable (#4624)
https://github.com/python/cpython/commit/5e3806f8cfd84722fc55d4299dc018ad9b0f8401
msg307286 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-30 10:49
Thanks Antoine and Nick for reviews and the feedback!
msg308162 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-12-12 22:15
New changeset 721e25c6535d08bd3d4d891fb2b540472e19f899 by Victor Stinner in branch 'master':
bpo-32101: Fix tests for PYTHONDEVMODE=1 (#4821)
https://github.com/python/cpython/commit/721e25c6535d08bd3d4d891fb2b540472e19f899
History
Date User Action Args
2022-04-11 14:58:54adminsetgithub: 76282
2017-12-12 22:15:02vstinnersetmessages: + msg308162
2017-12-12 21:55:06vstinnersetpull_requests: + pull_request4712
2017-11-30 10:49:45vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg307286

stage: patch review -> resolved
2017-11-30 10:40:27vstinnersetmessages: + msg307284
2017-11-29 00:09:04vstinnersetmessages: + msg307195
2017-11-29 00:07:18vstinnersetpull_requests: + pull_request4539
2017-11-21 03:48:22ncoghlansetmessages: + msg306625
2017-11-21 02:59:15vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request4423
2017-11-21 02:58:57vstinnercreate