Skip to content

Commit db5a6a0

Browse files
Fix regression introduced way back in the AST code
1 parent 17f54d5 commit db5a6a0

3 files changed

Lines changed: 9 additions & 20 deletions

File tree

Lib/test/test_ast.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,12 @@ def test_literal_eval_issue4907(self):
494494

495495

496496
def test_main():
497-
with test_support.check_py3k_warnings(("backquote not supported",
498-
SyntaxWarning)):
497+
deprecations = []
498+
if sys.py3kwarning:
499+
deprecations += [
500+
("backquote not supported", SyntaxWarning),
501+
("the L suffix is not supported in 3.x; drop the suffix", SyntaxWarning)]
502+
with test_support.check_warnings(*deprecations):
499503
test_support.run_unittest(AST_Tests, ASTHelpers_Test)
500504

501505
def main():

Lib/test/test_optparse.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,9 +1655,8 @@ def test_numeric_options(self):
16551655
"option -l: invalid long integer value: '0x12x'")
16561656

16571657
def test_parse_num_3k_warnings(self):
1658-
expected = 'the L suffix is not supported in 3.x; simply drop the suffix, \
1659-
or accept the auto fixer modifications'
1660-
with check_py3k_warnings((expected, Py3xWarning)):
1658+
expected = 'the L suffix is not supported in 3.x; drop the suffix'
1659+
with test_support.check_warnings():
16611660
x = 10L
16621661
y = 8L
16631662
z = x + y

Python/ast.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,6 @@ ast_warn(struct compiling *c, const node *n, char *msg)
130130
return 1;
131131
}
132132

133-
static int
134-
ast_3x_warn(struct compiling *c, const node *n, char *msg)
135-
{
136-
if (PyErr_WarnExplicit(PyExc_Py3xWarning, msg, c->c_filename, LINENO(n),
137-
NULL, NULL) < 0) {
138-
/* if -Werr, change it to a SyntaxError */
139-
if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_Py3xWarning))
140-
ast_error(n, msg);
141-
return 0;
142-
}
143-
return 1;
144-
}
145-
146133
static int
147134
forbidden_check(struct compiling *c, const node *n, const char *x)
148135
{
@@ -3355,8 +3342,7 @@ parsenumber(struct compiling *c, const node *n, const char *s)
33553342
#endif
33563343
if (*end == 'l' || *end == 'L') {
33573344
if (Py_Py3kWarningFlag &&
3358-
!ast_3x_warn(c, n, "the L suffix is not supported in 3.x; simply drop the suffix, \n"
3359-
"or accept the auto fixer modifications")) {
3345+
!ast_warn(c, n, "the L suffix is not supported in 3.x; drop the suffix")) {
33603346
return NULL;
33613347
}
33623348
return PyLong_FromString((char *)s, (char **)0, 0);

0 commit comments

Comments
 (0)