diff options
author | lb_ii <lolbot_iichan@mail.ru> | 2020-07-12 16:13:22 +0300 |
---|---|---|
committer | lb_ii <lolbot_iichan@mail.ru> | 2020-07-12 18:10:51 +0300 |
commit | 8b87d22ddc5bc8b73af7f2f3cef9feb433900d35 (patch) | |
tree | bd2b8009c46aaf542dcab58d0bf50f0917e3b8b6 | |
parent | f5342b9d4a89e8e4bb9cb43821370f6094a5778c (diff) | |
download | ply-8b87d22ddc5bc8b73af7f2f3cef9feb433900d35.tar.gz |
GARDENSNAKE: Fix various Python 3 issues
-rw-r--r-- | example/GardenSnake/GardenSnake.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/example/GardenSnake/GardenSnake.py b/example/GardenSnake/GardenSnake.py index af70b0b..139e9eb 100644 --- a/example/GardenSnake/GardenSnake.py +++ b/example/GardenSnake/GardenSnake.py @@ -83,7 +83,7 @@ def t_NUMBER(t): def t_STRING(t): r"'([^\\']+|\\'|\\\\)*'" # I think this is right ... - t.value = t.value[1:-1].decode("string-escape") # .swapcase() # for fun + t.value = t.value[1:-1].encode().decode("unicode_escape") # .swapcase() # for fun return t t_COLON = r':' @@ -342,7 +342,7 @@ class IndentLexer(object): def input(self, s, add_endmarker=True): self.lexer.paren_count = 0 self.lexer.input(s) - self.token_stream = list(filter(self.lexer, add_endmarker)) + self.token_stream = filter(self.lexer, add_endmarker) def token(self): try: @@ -356,7 +356,7 @@ class IndentLexer(object): #import yacc # I use the Python AST -from compiler import ast +import ast # Helper function @@ -769,11 +769,6 @@ print('BIG DECIMAL', 1.234567891234567e12345) # Set up the GardenSnake run-time environment -def print_(*args): - print("-->", " ".join(map(str, args))) - -globals()["print"] = print_ - compiled_code = compile(code) exec(compiled_code, globals()) |