From 90fe31688d75621544bf95f09d60ab4522f5309f Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 5 Jul 2009 21:23:05 +0200 Subject: [PATCH] fix TreeFragment: parsing works on Unicode streams --- Cython/Compiler/TreeFragment.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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) -- 2.26.2