Commits

Almar Klein committed 9702647

Fixed issue #254: codeeditor py2k compat

  • Participants
  • Parent commits 0d5bec3

Comments (0)

Files changed (3)

iep/codeeditor/parsers/__init__.py

 #import zipfile
 from . import tokens
 
+if sys.version_info[0] >= 3:
+    text_type = str
+else:
+    text_type = unicode 
+    
 
 class BlockState(object):
     """ BlockState(state=0, info=None)

iep/codeeditor/parsers/c_parser.py

 # The full license can be found in 'license.txt'.
 
 import re
-from . import tokens, Parser, BlockState
+from . import tokens, Parser, BlockState, text_type
 from .tokens import ALPHANUM
 
 from .tokens import (Token, CommentToken, StringToken, 
         Parses a line of C code, yielding tokens.
         
         """ 
+        line = text_type(line)
         
         pos = 0 # Position following the previous match
         

iep/codeeditor/parsers/python_parser.py

 # The full license can be found in 'license.txt'.
 
 import re
-from . import tokens, Parser, BlockState
+from . import tokens, Parser, BlockState, text_type
 from .tokens import ALPHANUM
 
 
         to handle line continuation and multiline strings.
         
         """ 
+        line = text_type(line)
         
         # Init
         pos = 0 # Position following the previous match