Python 3 DUP_TOP_TWO bug

This commit is contained in:
rocky 2016-05-08 18:41:39 -04:00
parent dddb486d78
commit 196495c40e
4 changed files with 12 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,6 @@
# Bug in &= ~x in Python 3
# Uses DUP_TOP_TWO in Python 3 and
# DUP_TOPX_2 in Python 2
import sys, termios
new = sys.argv[:]
new[3] &= ~termios.ECHO

View File

@ -332,6 +332,9 @@ class Python2Parser(PythonParser):
slice2 ::= expr expr DUP_TOPX_2 SLICE+2
slice3 ::= expr expr expr SLICE+3
slice3 ::= expr expr expr DUP_TOPX_3 SLICE+3
# In Python 3, DUP_TOPX_2 is DUP_TOP_TWO
binary_subscr2 ::= expr expr DUP_TOPX_2 BINARY_SUBSCR
'''
def add_custom_rules(self, tokens, customize):

View File

@ -344,6 +344,9 @@ class Python3Parser(PythonParser):
# Python 3.3+ adds yield from
expr ::= yield_from
yield_from ::= expr expr YIELD_FROM
# In Python 2, DUP_TOP_TWO is DUP_TOPX_2
binary_subscr2 ::= expr expr DUP_TOP_TWO BINARY_SUBSCR
'''
@staticmethod