summaryrefslogtreecommitdiff
path: root/ply
diff options
context:
space:
mode:
authorDavid Beazley <dave@dabeaz.com>2013-05-29 15:35:42 -0500
committerDavid Beazley <dave@dabeaz.com>2013-05-29 15:35:42 -0500
commit1b66128ac860a7429f1954a86c4ab8f63a0e8b92 (patch)
tree0bb2da35e3b0cbcb7e689e7abf9144d0e34e9844 /ply
parentea655a3a8632824f5e0fb2319f096d5f9579bff7 (diff)
downloadply-1b66128ac860a7429f1954a86c4ab8f63a0e8b92.tar.gz
Fixed from __future__ import unicode_literals bug
Diffstat (limited to 'ply')
-rw-r--r--ply/yacc.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/ply/yacc.py b/ply/yacc.py
index 67eff06..7cd0b07 100644
--- a/ply/yacc.py
+++ b/ply/yacc.py
@@ -94,6 +94,12 @@ else:
def func_code(f):
return f.__code__
+# String type-checking compatibility
+if sys.version_info[0] < 3:
+ string_types = basestring
+else:
+ string_types = str
+
# Compatibility
try:
MAXINT = sys.maxint
@@ -2904,7 +2910,7 @@ class ParserReflect(object):
# Validate the start symbol
def validate_start(self):
if self.start is not None:
- if not isinstance(self.start,str):
+ if not isinstance(self.start, string_types):
self.log.error("'start' must be a string")
# Look for error handler
@@ -2990,16 +2996,16 @@ class ParserReflect(object):
self.error = 1
return
assoc = p[0]
- if not isinstance(assoc,str):
+ if not isinstance(assoc, string_types):
self.log.error("precedence associativity must be a string")
self.error = 1
return
for term in p[1:]:
- if not isinstance(term,str):
+ if not isinstance(term, string_types):
self.log.error("precedence items must be strings")
self.error = 1
return
- preclist.append((term,assoc,level+1))
+ preclist.append((term, assoc, level+1))
self.preclist = preclist
# Get all p_functions from the grammar