summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/patcomp.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/lib2to3/patcomp.py')
-rw-r--r--Lib/lib2to3/patcomp.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/lib2to3/patcomp.py b/Lib/lib2to3/patcomp.py
index f57f495..49ed668 100644
--- a/Lib/lib2to3/patcomp.py
+++ b/Lib/lib2to3/patcomp.py
@@ -11,7 +11,7 @@ The compiler compiles a pattern to a pytree.*Pattern instance.
__author__ = "Guido van Rossum <guido@python.org>"
# Python imports
-import io
+import StringIO
# Fairly local imports
from .pgen2 import driver, literals, token, tokenize, parse, grammar
@@ -27,8 +27,8 @@ class PatternSyntaxError(Exception):
def tokenize_wrapper(input):
"""Tokenizes a string suppressing significant whitespace."""
- skip = {token.NEWLINE, token.INDENT, token.DEDENT}
- tokens = tokenize.generate_tokens(io.StringIO(input).readline)
+ skip = set((token.NEWLINE, token.INDENT, token.DEDENT))
+ tokens = tokenize.generate_tokens(StringIO.StringIO(input).readline)
for quintuple in tokens:
type, value, start, end, line_text = quintuple
if type not in skip:
@@ -58,7 +58,7 @@ class PatternCompiler(object):
try:
root = self.driver.parse_tokens(tokens, debug=debug)
except parse.ParseError as e:
- raise PatternSyntaxError(str(e)) from None
+ raise PatternSyntaxError(str(e))
if with_tree:
return self.compile_node(root), root
else:
@@ -140,7 +140,7 @@ class PatternCompiler(object):
assert len(nodes) >= 1
node = nodes[0]
if node.type == token.STRING:
- value = str(literals.evalString(node.value))
+ value = unicode(literals.evalString(node.value))
return pytree.LeafPattern(_type_of_literal(value), value)
elif node.type == token.NAME:
value = node.value