Terry J. Reedy <tjre...@udel.edu> added the comment:

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.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35798>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to