Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-32101: Add PYTHONDEVMODE environment variable #4624

Merged
merged 4 commits into from Nov 30, 2017
Merged

bpo-32101: Add PYTHONDEVMODE environment variable #4624

merged 4 commits into from Nov 30, 2017

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Nov 29, 2017

Add also the sys.flags.dev_mode flag.

https://bugs.python.org/issue32101

@vstinner vstinner requested a review from pitrou November 29, 2017 00:03
@vstinner vstinner requested a review from 1st1 as a code owner November 29, 2017 00:03
@vstinner vstinner changed the title bpo-321010: Add PYTHONDEVMODE environment variable bpo-32101: Add PYTHONDEVMODE environment variable Nov 29, 2017
@vstinner
Copy link
Member Author

Oh, test_sys fails in development mode, but it's unrelated to this PR: bug fixed by PR #4625.

Another bug: test_faulthandler and test_asyncio now fail with PYTHONDEVMODE=1.

Rename also the "Developer mode" to the "Development mode".
Mention it in the development chapiter.
@vstinner
Copy link
Member Author

I rebased my change to get the memory allocator fixes (commit 5d39e04), and I documented the "Python development mode" in the Development chapiter of the documentation.

@vstinner
Copy link
Member Author

Ok, the patch now works properly, and the full Python test suite pass with PYTHONDEVMODE=1.

@ncoghlan, @pitrou: What do you think of adding sys.flags.dev_mode?

I chose to make sys.flags.dev_mode a boolean, whereas other flags are integer and have a Py_xxx variable in C.

Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I'm OK with the idea of committing to dev mode being an "all or nothing" toggle - the more fine-grained control already exists in the form of the underlying settings that dev mode groups together.

@@ -31,7 +31,7 @@ def _is_debug_mode():
# when _DEBUG is true.
debug = (not sys.flags.ignore_environment and
bool(os.environ.get('PYTHONASYNCIODEBUG')))
if hasattr(sys, '_xoptions') and 'dev' in sys._xoptions:
if sys.flags.dev_mode:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the second check is shorter, this could be simplified to:

debug = sys.flags.dev_mode or (not sys.flags.ignore_environment and
                               bool(os.environ.get('PYTHONASYNCIODEBUG'))
return debug

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@vstinner vstinner merged commit 5e3806f into python:master Nov 30, 2017
@vstinner vstinner deleted the pythondevmode branch November 30, 2017 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants