summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ply/lex.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/ply/lex.py b/ply/lex.py
index 24908b4..dd85bac 100644
--- a/ply/lex.py
+++ b/ply/lex.py
@@ -200,7 +200,9 @@ class Lexer(object):
# input() - Push a new string into the lexer
# ------------------------------------------------------------
def input(self,s):
- if not (isinstance(s,types.StringType) or isinstance(s,types.UnicodeType)):
+ # Pull off the first character to see if s looks like a string
+ c = s[:1]
+ if not (isinstance(c,types.StringType) or isinstance(c,types.UnicodeType)):
raise ValueError, "Expected a string"
self.lexdata = s
self.lexpos = 0