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

duplicate SyntaxWarning: "is" with a literal #79979

Closed
jwilk mannequin opened this issue Jan 21, 2019 · 7 comments
Closed

duplicate SyntaxWarning: "is" with a literal #79979

jwilk mannequin opened this issue Jan 21, 2019 · 7 comments
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@jwilk
Copy link
Mannequin

jwilk mannequin commented Jan 21, 2019

BPO 35798
Nosy @terryjreedy, @vstinner, @jwilk, @serhiy-storchaka, @kakshay21
PRs
  • bpo-35798: Fix duplicate SyntaxWarning: "is" with a literal. #11639
  • bpo-35798: Fix duplicate SyntaxWarning: "is" with a literal. #11639
  • bpo-35798: Fix duplicate SyntaxWarning: "is" with a literal. #11639
  • bpo-35798: Remove redundant warning #11642
  • bpo-35798: Remove redundant warning #11642
  • bpo-35798: Remove redundant warning #11642
  • bpo-35798: Add test.support.check_syntax_warning(). #11895
  • 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-02-19.06:48:16.577>
    created_at = <Date 2019-01-21.15:13:45.389>
    labels = ['interpreter-core', 'type-bug', '3.8']
    title = 'duplicate SyntaxWarning: "is" with a literal'
    updated_at = <Date 2019-02-19.06:48:16.576>
    user = 'https://github.com/jwilk'

    bugs.python.org fields:

    activity = <Date 2019-02-19.06:48:16.576>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-02-19.06:48:16.577>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2019-01-21.15:13:45.389>
    creator = 'jwilk'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35798
    keywords = ['patch', 'patch', 'patch']
    message_count = 7.0
    messages = ['334143', '334144', '334169', '334366', '335670', '335671', '335891']
    nosy_count = 5.0
    nosy_names = ['terry.reedy', 'vstinner', 'jwilk', 'serhiy.storchaka', 'kakshay']
    pr_nums = ['11639', '11639', '11639', '11642', '11642', '11642', '11895']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue35798'
    versions = ['Python 3.8']

    @jwilk
    Copy link
    Mannequin Author

    jwilk mannequin commented Jan 21, 2019

    $ python3.8 -c 'if object() is 42: pass'
    <string>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
    <string>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?

    I'd like only one copy of this warning, not two.

    Tested with git master (e9b185f).

    @jwilk jwilk mannequin added 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jan 21, 2019
    @vstinner
    Copy link
    Member

    The warning has been introduced by bpo-34850: commit 3bcbedc.

    @kakshay21
    Copy link
    Mannequin

    kakshay21 mannequin commented Jan 21, 2019

    can I work on this?

    @terryjreedy
    Copy link
    Member

    I verified that master on Windows (which requires " instead of ')

    python -c "if object() is 42: pass"
    results in the doubled messsage, and that after applying PR 11639 and recompiling, there is only 1 message.

    We should test that exactly 1 warning is emitted. The following fails on master and passes with the parch:

    import unittest, warnings
    
    class SyntaxWarningTest(unittest.TestCase):
        def test_syntax_warning_once(self):
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter("always")
                compile('if object() is 42: pass\n', '', 'single')
                self.assertEqual(len(w), 1)  # Not 2, see issue 35798
    
    if __name__ == '__main__':
        unittest.main()
        
    The original patch added test_comparison_is_literal() in test_grammar.  The 'with' block above could be added at the end.

    @serhiy-storchaka
    Copy link
    Member

    This warning is not special. I'll add a helper for testing that all syntax warnings are emitted only once later.

    @serhiy-storchaka
    Copy link
    Member

    New changeset 4583525 by Serhiy Storchaka in branch 'master':
    bpo-35798: Fix duplicate SyntaxWarning: "is" with a literal. (GH-11639)
    4583525

    @serhiy-storchaka
    Copy link
    Member

    New changeset e7a4bb5 by Serhiy Storchaka in branch 'master':
    bpo-35798: Add test.support.check_syntax_warning(). (bpo-11895)
    e7a4bb5

    @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 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants