Commit 719a49e2 authored by Mark Florisson's avatar Mark Florisson

Include pyximport in testrunner for py3k and fix py3k unicode fused bug

parent f69d1c2a
...@@ -1948,11 +1948,11 @@ class PyxCodeWriter(object): ...@@ -1948,11 +1948,11 @@ class PyxCodeWriter(object):
to load the code to support python 2.4 to load the code to support python 2.4
""" """
def __init__(self, buffer=None, indent_level=0, context=None): def __init__(self, buffer=None, indent_level=0, context=None, encoding='ascii'):
self.buffer = buffer or StringIOTree() self.buffer = buffer or StringIOTree()
self.level = indent_level self.level = indent_level
self.context = context self.context = context
self.encoding = 'ascii' self.encoding = encoding
def indent(self, levels=1): def indent(self, levels=1):
self.level += levels self.level += levels
...@@ -1969,7 +1969,11 @@ class PyxCodeWriter(object): ...@@ -1969,7 +1969,11 @@ class PyxCodeWriter(object):
return self return self
def getvalue(self): def getvalue(self):
return unicode(self.buffer.getvalue(), self.encoding) result = self.buffer.getvalue()
if not isinstance(result, unicode):
result = result.decode(self.encoding)
return result
def putln(self, line, context=None): def putln(self, line, context=None):
context = context or self.context context = context or self.context
......
from __future__ import with_statement
import copy import copy
from Cython.Compiler import (ExprNodes, PyrexTypes, MemoryView, from Cython.Compiler import (ExprNodes, PyrexTypes, MemoryView,
...@@ -605,8 +607,7 @@ class FusedCFuncDefNode(StatListNode): ...@@ -605,8 +607,7 @@ class FusedCFuncDefNode(StatListNode):
fragment_code = pyx_code.getvalue() fragment_code = pyx_code.getvalue()
# print decl_code.getvalue() # print decl_code.getvalue()
# print fragment_code # print fragment_code
fragment = TreeFragment.TreeFragment(fragment_code.decode('ascii'), fragment = TreeFragment.TreeFragment(fragment_code, level='module')
level='module')
ast = TreeFragment.SetPosTransform(self.node.pos)(fragment.root) ast = TreeFragment.SetPosTransform(self.node.pos)(fragment.root)
UtilityCode.declare_declarations_in_scope(decl_code.getvalue(), env) UtilityCode.declare_declarations_in_scope(decl_code.getvalue(), env)
ast.scope = env ast.scope = env
......
...@@ -40,7 +40,7 @@ def importer(modulename, compile=False, version=None): ...@@ -40,7 +40,7 @@ def importer(modulename, compile=False, version=None):
Otherwise, try a regular import and if that fails (i.e. there is a Otherwise, try a regular import and if that fails (i.e. there is a
syntax error, try to compile it. syntax error, try to compile it.
""" """
if version is not None and sys.version_info[:2] >= version: if version is not None and sys.version_info[:2] >= version and not compile:
return _import_normal(modulename) return _import_normal(modulename)
if compile: if compile:
......
...@@ -1489,7 +1489,8 @@ if VALUE is not None: ...@@ -1489,7 +1489,8 @@ if VALUE is not None:
return node return node
FusedNode = Importer.importer("Cython.Compiler.FusedNode", version=(2, 5)) FusedNode = Importer.importer("Cython.Compiler.FusedNode",
version=(2, 5))
node = FusedNode.FusedCFuncDefNode(node, env) node = FusedNode.FusedCFuncDefNode(node, env)
self.fused_function = node self.fused_function = node
......
...@@ -1251,6 +1251,8 @@ def refactor_for_py3(distdir, cy3_dir): ...@@ -1251,6 +1251,8 @@ def refactor_for_py3(distdir, cy3_dir):
recursive-include Cython *.py *.pyx *.pxd recursive-include Cython *.py *.pyx *.pxd
recursive-include Cython/Debugger/Tests * recursive-include Cython/Debugger/Tests *
recursive-include Cython/Utility * recursive-include Cython/Utility *
recursive-exclude pyximport test
include pyximport/*.py
include runtests.py include runtests.py
include cython.py include cython.py
''') ''')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment