bpo-33645: Fix an "unknown parsing error" in the parser. (GH-7119)
It is reproduced when parse the "<>" operator and run
Python with both options -3 and -We.
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 23b6ce8..228586e 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -5,6 +5,7 @@
check_py3k_warnings
import unittest
import sys
+import warnings
# testing import *
from sys import *
@@ -628,7 +629,6 @@
with check_py3k_warnings((warntext, DeprecationWarning)):
compile(code, '<test string>', 'exec')
if sys.py3kwarning:
- import warnings
with warnings.catch_warnings():
warnings.filterwarnings('error', category=DeprecationWarning)
with self.assertRaises(SyntaxError) as cm:
@@ -883,6 +883,13 @@
with check_py3k_warnings(('<> not supported in 3.x; use !=',
DeprecationWarning)):
if eval('1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1'): pass
+ if sys.py3kwarning:
+ with warnings.catch_warnings():
+ warnings.filterwarnings('error', category=DeprecationWarning)
+ with self.assertRaises(DeprecationWarning) as cm:
+ compile('1 <> 1', '<test string>', 'eval')
+ self.assertIn('<> not supported in 3.x; use !=',
+ str(cm.exception))
def test_binary_mask_ops(self):
x = 1 & 1