Issue 32101: Add PYTHONDEVMODE=1 to enable the developer mode
Issue32101
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) * ![]() |
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: Alyssa Coghlan (ncoghlan) * ![]() |
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) * ![]() |
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) * ![]() |
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) * ![]() |
Date: 2017-11-30 10:49 | |
Thanks Antoine and Nick for reviews and the feedback! |
|||
| msg308162 - (view) | Author: STINNER Victor (vstinner) * ![]() |
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:54 | admin | set | github: 76282 |
| 2017-12-12 22:15:02 | vstinner | set | messages: + msg308162 |
| 2017-12-12 21:55:06 | vstinner | set | pull_requests: + pull_request4712 |
| 2017-11-30 10:49:45 | vstinner | set | status: open -> closed resolution: fixed messages: + msg307286 stage: patch review -> resolved |
| 2017-11-30 10:40:27 | vstinner | set | messages: + msg307284 |
| 2017-11-29 00:09:04 | vstinner | set | messages: + msg307195 |
| 2017-11-29 00:07:18 | vstinner | set | pull_requests: + pull_request4539 |
| 2017-11-21 03:48:22 | ncoghlan | set | messages: + msg306625 |
| 2017-11-21 02:59:15 | vstinner | set | keywords:
+ patch stage: patch review pull_requests: + pull_request4423 |
| 2017-11-21 02:58:57 | vstinner | create | |
