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

-W command line options and PYTHONWARNINGS environmental variable should not override -b / -bb command line options #64560

Closed
Arfrever mannequin opened this issue Jan 23, 2014 · 8 comments
Labels
3.7 interpreter-core type-bug

Comments

@Arfrever
Copy link
Mannequin

@Arfrever Arfrever mannequin commented Jan 23, 2014

BPO 20361
Nosy @warsaw, @brettcannon, @ncoghlan, @pitrou, @vstinner, @larryhastings, @pjenvey, @jwilk, @ezio-melotti, @merwok, @briancurtin, @serhiy-storchaka, @jdufresne
PRs
  • #4734
  • #4820
  • #5283
  • Dependencies
  • bpo-20363: BytesWarnings triggerred by test suite
  • Files
  • python-bytes_warnings.patch
  • 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-12-12.22:01:13.847>
    created_at = <Date 2014-01-23.09:19:49.506>
    labels = ['interpreter-core', 'type-bug', '3.7']
    title = '-W command line options and PYTHONWARNINGS environmental variable should not override -b / -bb command line options'
    updated_at = <Date 2018-01-23.12:30:55.712>
    user = 'https://bugs.python.org/Arfrever'

    bugs.python.org fields:

    activity = <Date 2018-01-23.12:30:55.712>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-12-12.22:01:13.847>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2014-01-23.09:19:49.506>
    creator = 'Arfrever'
    dependencies = ['20363']
    files = ['33648']
    hgrepos = []
    issue_num = 20361
    keywords = ['patch']
    message_count = 8.0
    messages = ['208894', '208898', '212095', '217439', '307792', '308157', '308158', '310500']
    nosy_count = 14.0
    nosy_names = ['barry', 'brett.cannon', 'ncoghlan', 'pitrou', 'vstinner', 'larry', 'pjenvey', 'jwilk', 'ezio.melotti', 'eric.araujo', 'Arfrever', 'brian.curtin', 'serhiy.storchaka', 'jdufresne']
    pr_nums = ['4734', '4820', '5283']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue20361'
    versions = ['Python 3.7']

    @Arfrever
    Copy link
    Mannequin Author

    @Arfrever Arfrever mannequin commented Jan 23, 2014

    Currently -W command line options and PYTHONWARNINGS environmental variable non-intuitively override settings specified by -b / -bb command line options.

    $ python3.4 -c 'print("" == b"")'
    False
    $ python3.4 -b -c 'print("" == b"")'
    -c:1: BytesWarning: Comparison between bytes and string
    False
    $ python3.4 -bb -c 'print("" == b"")'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    BytesWarning: Comparison between bytes and string
    $ python3.4 -We -b -c 'print("" == b"")'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    BytesWarning: Comparison between bytes and string
    $ python3.4 -Wd -bb -c 'print("" == b"")'
    -c:1: BytesWarning: Comparison between bytes and string
    False
    $ python3.4 -Wi -b -c 'print("" == b"")'
    False
    $ python3.4 -Wi -bb -c 'print("" == b"")'
    False
    $

    I suggest to increase priority of -b / -bb command line options.
    The attached patch should be applied after patch from issue bpo-20355.

    (Test suite of Python triggers some BytesWarnings, so firstly they will have to be fixed.)

    @Arfrever Arfrever mannequin added interpreter-core type-bug labels Jan 23, 2014
    @Arfrever
    Copy link
    Mannequin Author

    @Arfrever Arfrever mannequin commented Jan 23, 2014

    By the way, Tools/scripts/run_tests.py (used by 'test' target in Makefile) passes '-W default -bb', which currently fails work as intended (i.e. treating BytesWarnings as errors).

    @serhiy-storchaka
    Copy link
    Member

    @serhiy-storchaka serhiy-storchaka commented Feb 24, 2014

    Final patch should remove a workaround in Tools/scripts/run_tests.py.

    @pitrou
    Copy link
    Member

    @pitrou pitrou commented Apr 28, 2014

    The patch is a bit problematic, because Py_BytesWarningFlag may also be set by e.g. an application embedding Python, but then Python's main.c won't be executed.

    @ncoghlan
    Copy link
    Contributor

    @ncoghlan ncoghlan commented Dec 7, 2017

    The approach I've taken in my PR is similar to the one that Arfrever proposed (albeit different in the details due to other changes in the startup code since that patch was written).

    For the embedding case, I've simply noted in the What's New section of the porting guide that embedding applications need to configure a error::BytesWarning filter explicitly if they want to treat BytesWarning as errors (in addition to setting the flag to request that the warnings be emitted in the first place).

    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Dec 12, 2017

    New changeset 747f48e by Victor Stinner in branch 'master':
    bpo-32230: Set sys.warnoptions with -X dev (bpo-4820)
    747f48e

    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Dec 12, 2017

    Ok, I merged Nick's PR: -b and -bb options now have the highest priority. I close the issue.

    @vstinner vstinner added the 3.7 label Jan 23, 2018
    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Jan 23, 2018

    New changeset dc6b946 by Victor Stinner in branch 'master':
    bpo-20361: Remove workaround for a now fixed bug (bpo-5283)
    dc6b946

    @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 interpreter-core type-bug
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants