From: Stefan Behnel Date: Sun, 5 Jul 2009 19:23:05 +0000 (+0200) Subject: fix TreeFragment: parsing works on Unicode streams X-Git-Tag: 0.12.alpha0~265 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=90fe31688d75621544bf95f09d60ab4522f5309f;p=cython.git fix TreeFragment: parsing works on Unicode streams --- diff --git a/Cython/Compiler/TreeFragment.py b/Cython/Compiler/TreeFragment.py index 28f9f8d4..66feaf09 100644 --- a/Cython/Compiler/TreeFragment.py +++ b/Cython/Compiler/TreeFragment.py @@ -3,10 +3,7 @@ # import re -try: - from cStringIO import BytesIO # Py3 mangled by 2to3 ... -except ImportError: - from cStringIO import StringIO as BytesIO # Py3 mangled by 2to3 ... +from StringIO import StringIO from Scanning import PyrexScanner, StringSourceDescriptor from Symtab import BuiltinScope, ModuleScope import Symtab @@ -57,7 +54,7 @@ def parse_from_strings(name, code, pxds={}, level=None, initial_pos=None): context = StringParseContext([], name) scope = context.find_module(module_name, pos = initial_pos, need_pxd = 0) - buf = BytesIO(code.encode(encoding)) + buf = StringIO(code) scanner = PyrexScanner(buf, code_source, source_encoding = encoding, scope = scope, context = context, initial_pos = initial_pos)