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

Add PYTHONDEVMODE=1 to enable the developer mode #76282

Closed
vstinner opened this issue Nov 21, 2017 · 6 comments
Closed

Add PYTHONDEVMODE=1 to enable the developer mode #76282

vstinner opened this issue Nov 21, 2017 · 6 comments
Labels
3.7 (EOL) end of life type-feature A feature request or enhancement

Comments

@vstinner
Copy link
Member

BPO 32101
Nosy @ncoghlan, @pitrou, @vstinner
PRs
  • bpo-32043: Rephrase -X dev documentation #4478
  • bpo-32101: Add PYTHONDEVMODE environment variable #4624
  • bpo-32101: Fix tests for PYTHONDEVMODE=1 #4821
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-11-30.10:49:45.114>
    created_at = <Date 2017-11-21.02:58:57.806>
    labels = ['type-feature', '3.7']
    title = 'Add PYTHONDEVMODE=1 to enable the developer mode'
    updated_at = <Date 2017-12-12.22:15:02.111>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2017-12-12.22:15:02.111>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-11-30.10:49:45.114>
    closer = 'vstinner'
    components = []
    creation = <Date 2017-11-21.02:58:57.806>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32101
    keywords = ['patch']
    message_count = 6.0
    messages = ['306618', '306625', '307195', '307284', '307286', '308162']
    nosy_count = 3.0
    nosy_names = ['ncoghlan', 'pitrou', 'vstinner']
    pr_nums = ['4478', '4624', '4821']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32101'
    versions = ['Python 3.7']

    @vstinner
    Copy link
    Member Author

    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.)

    @vstinner vstinner added 3.7 (EOL) end of life type-feature A feature request or enhancement labels Nov 21, 2017
    @ncoghlan
    Copy link
    Contributor

    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.

    @vstinner
    Copy link
    Member Author

    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.

    @vstinner
    Copy link
    Member Author

    New changeset 5e3806f by Victor Stinner in branch 'master':
    bpo-32101: Add PYTHONDEVMODE environment variable (bpo-4624)
    5e3806f

    @vstinner
    Copy link
    Member Author

    Thanks Antoine and Nick for reviews and the feedback!

    @vstinner
    Copy link
    Member Author

    New changeset 721e25c by Victor Stinner in branch 'master':
    bpo-32101: Fix tests for PYTHONDEVMODE=1 (bpo-4821)
    721e25c

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants