]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-43497: Emit SyntaxWarnings for assertions with tuple constants. (GH-24867)
authortsukasa-au <tsukasa-au@users.noreply.github.com>
Tue, 16 Mar 2021 11:14:41 +0000 (22:14 +1100)
committerGitHub <noreply@github.com>
Tue, 16 Mar 2021 11:14:41 +0000 (11:14 +0000)
commita8ef4572a6b28bcfc0b10b34fa4204954b9dd761
tree59548765f737b26d8e8fa57b49dabad8f57a5365
parent1330338583d183250186a8123b99d2283e945b4f
bpo-43497: Emit SyntaxWarnings for assertions with tuple constants. (GH-24867)

* bpo-43497: Emit SyntaxWarnings for assertions with tuple constants.

Add a test that shows that a tuple constant (a tuple, where all of its
members are also compile-time constants) produces a SyntaxWarning. Then
fix this failure.

* Make SyntaxWarnings also work when "optimized".

* Split tests for SyntaxWarning to SyntaxError conversion

SyntaxWarnings emitted by the compiler when configured to be errors are
actually raised as SyntaxError exceptions.

Move these tests into their own method and add a test to ensure they are
raised. Previously we only tested that they were not raised for a
"valid" assertion statement.
Lib/test/test_grammar.py
Misc/NEWS.d/next/Core and Builtins/2021-03-15-07-50-30.bpo-43497.Uc5ZCJ.rst [new file with mode: 0644]
Python/compile.c