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
Comments
$ 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). |
can I work on this? |
I verified that master on Windows (which requires " instead of ')
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. |
This warning is not special. I'll add a helper for testing that all syntax warnings are emitted only once later. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: