Skip to content

Add PYTHONDEVMODE=1 to enable the developer mode #76282

Closed

Description

@vstinner
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']

    Activity

    1. vstinner commented on Nov 21, 2017

      @vstinner
      MemberAuthor

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

    2. ncoghlan commented on Nov 21, 2017

      @ncoghlan
      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.

    3. vstinner commented on Nov 29, 2017

      @vstinner
      MemberAuthor

      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.

    4. vstinner commented on Nov 30, 2017

      @vstinner
      MemberAuthor

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

    5. vstinner commented on Nov 30, 2017

      @vstinner
      MemberAuthor

      Thanks Antoine and Nick for reviews and the feedback!

    6. vstinner commented on Dec 12, 2017

      @vstinner
      MemberAuthor

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

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of lifetype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions