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

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

Closed
vstinner opened this issue Sep 29, 2019 · 4 comments
Closed
Labels
3.8 (EOL) end of life 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@vstinner
Copy link
Member

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

    @vstinner
    Copy link
    Member Author

    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

    @vstinner vstinner added 3.8 (EOL) end of life 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Sep 29, 2019
    @vstinner
    Copy link
    Member Author

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

    @miss-islington
    Copy link
    Contributor

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

    @vstinner
    Copy link
    Member Author

    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

    @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.8 (EOL) end of life 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants