Skip to content

PyConfig (PEP 587): PyConfig.warnoptions should have the highest priority #82498

Closed

Description

@vstinner
BPO 38317
Nosy @ncoghlan, @vstinner, @miss-islington
PRs
  • bpo-38317: Fix PyConfig.warnoptions priority #16478
  • [3.8] bpo-38317: Fix PyConfig.warnoptions priority (GH-16478) #16479
  • 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 2019-09-30.00:29:52.741>
    created_at = <Date 2019-09-29.22:54:37.599>
    labels = ['interpreter-core', '3.8', '3.9']
    title = 'PyConfig (PEP 587): PyConfig.warnoptions should have the highest priority'
    updated_at = <Date 2019-09-30.00:29:52.735>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-09-30.00:29:52.735>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-09-30.00:29:52.741>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2019-09-29.22:54:37.599>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38317
    keywords = ['patch']
    message_count = 4.0
    messages = ['353513', '353514', '353516', '353518']
    nosy_count = 3.0
    nosy_names = ['ncoghlan', 'vstinner', 'miss-islington']
    pr_nums = ['16478', '16479']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue38317'
    versions = ['Python 3.8', 'Python 3.9']

    Activity

    1. vstinner commented on Sep 29, 2019

      @vstinner
      MemberAuthor

      The PEP-587 says that PyConfig.warnoptions has the highest priority for warnings options:
      https://www.python.org/dev/peps/pep-0587/#priority-and-rules

      But in the current implementation, PyConfig.warnoptions has... the lowest priority :-(

      Attached PR not only fix the issue but also add tests to ensure that every ways to set warnings options have the expected priority.

      Priority of warnings options, lowest to highest:

      • any implicit filters added by _warnings.c/warnings.py
      • PyConfig.dev_mode: "default" filter
      • PYTHONWARNINGS environment variable
      • '-W' command line options
      • PyConfig.bytes_warning ('-b', '-bb'): "default::BytesWarning"
        or "error::BytesWarning" filter
      • early PySys_AddWarnOption() calls
      • PyConfig.warnoptions
    2. vstinner commented on Sep 29, 2019

      @vstinner
      MemberAuthor

      New changeset fb4ae15 by Victor Stinner in branch 'master':
      bpo-38317: Fix PyConfig.warnoptions priority (GH-16478)
      fb4ae15

    3. miss-islington commented on Sep 29, 2019

      @miss-islington
      Contributor

      New changeset c9ed9e6 by Miss Islington (bot) in branch '3.8':
      bpo-38317: Fix PyConfig.warnoptions priority (GH-16478)
      c9ed9e6

    4. vstinner commented on Sep 30, 2019

      @vstinner
      MemberAuthor

      Oh, the documentation in the PEP-587 was also wrong. I updated it:
      python/peps@16bc282

      The "warnings options priority" is currently not documented at:
      https://docs.python.org/dev/c-api/init_config.html

      The latest major change was bpo-20361 when -b command line option changed to get the highest priority (-b > -W).

      cc Nick Coghlan

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

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions