Commits

Juancarlo Añez  committed 7ba0409

Unicode treatement between 2.7 and 3.3

  • Participants
  • Parent commits 2bae936

Comments (0)

Files changed (3)

File examples/antlr2grako/antlr2grako.py

 # -*- coding: utf-8 -*-
 from __future__ import print_function, division, absolute_import, unicode_literals
 import sys
+import io
 from os import path
 from grako.buffering import Buffer
 from antlr_parser import ANTLRParser as ANTLRParserBase
                                               'grammar',
                                               filename=filename,
                                               **kwargs)
+
+
 def main(filename, trace):
     parser = ANTLRParser()
-    with open(filename) as f:
+    with io.open(filename) as f:
         buffer = Buffer(f.read(),
                         filename=filename,
                         comments_re=COMMENTS_RE,
                              trace=trace)
         print(model)
 
+
 if __name__ == '__main__':
     if len(sys.argv) < 2:
         thisprog = path.basename(sys.argv[0])

File grako/buffering.py

             return ''
         info = self.line_info()
         text = info.text[info.col:info.col + 1 + 80]
-        text = text.split('\n')[0].encode('unicode-escape')
+        text = text.split('\n')[0]
         return '<%d:%d>%s' % (info.line + 1, info.col + 1, text)
 
     def get_line(self, n=None):

File grako/contexts.py

 
     def _trace(self, msg, *params):
         if self.trace:
-            print((msg % params).encode(self.encoding), file=sys.stderr)
+            print(msg % params, file=sys.stderr)
 
     def _trace_event(self, event):
         if self.trace: