Kaydet (Commit) 2fe3ef87 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

change Py3k backquote warning to a SyntaxWarning and add a test

üst 1f1174ed
...@@ -10,6 +10,12 @@ if not sys.py3kwarning: ...@@ -10,6 +10,12 @@ if not sys.py3kwarning:
class TestPy3KWarnings(unittest.TestCase): class TestPy3KWarnings(unittest.TestCase):
def test_backquote(self):
expected = 'backquote not supported in 3.x; use repr()'
with catch_warning() as w:
exec "`2`" in {}
self.assertWarning(None, w, expected)
def test_type_inequality_comparisons(self): def test_type_inequality_comparisons(self):
expected = 'type inequality comparisons not supported in 3.x' expected = 'type inequality comparisons not supported in 3.x'
with catch_warning() as w: with catch_warning() as w:
......
...@@ -1364,7 +1364,7 @@ ast_for_atom(struct compiling *c, const node *n) ...@@ -1364,7 +1364,7 @@ ast_for_atom(struct compiling *c, const node *n)
case BACKQUOTE: { /* repr */ case BACKQUOTE: { /* repr */
expr_ty expression; expr_ty expression;
if (Py_Py3kWarningFlag) { if (Py_Py3kWarningFlag) {
if (PyErr_WarnExplicit(PyExc_DeprecationWarning, if (PyErr_WarnExplicit(PyExc_SyntaxWarning,
"backquote not supported in 3.x; use repr()", "backquote not supported in 3.x; use repr()",
c->c_filename, LINENO(n), c->c_filename, LINENO(n),
NULL, NULL)) { NULL, NULL)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment