From 745ac5d9cba463f7ceb6b4109b067e47c2881a33 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 21 Aug 2009 09:50:05 +0200 Subject: [PATCH] Py3 fix --- Cython/Compiler/Buffer.py | 4 ++-- Cython/Compiler/Nodes.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/Buffer.py b/Cython/Compiler/Buffer.py index bfcedc9c..b297ad15 100644 --- a/Cython/Compiler/Buffer.py +++ b/Cython/Compiler/Buffer.py @@ -146,8 +146,8 @@ def analyse_buffer_options(globalpos, env, posargs, dictargs, defaults=None, nee for name, (value, pos) in dictargs.iteritems(): if not name in buffer_options: raise CompileError(pos, ERR_BUF_OPTION_UNKNOWN % name) - options[name.encode("ASCII")] = value - + options[name] = value + for name, (value, pos) in zip(buffer_options, posargs): if not name in buffer_options: raise CompileError(pos, ERR_BUF_OPTION_UNKNOWN % name) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 1c816692..da818675 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -735,6 +735,11 @@ class CBufferAccessTypeNode(CBaseTypeNode): self.keyword_args, base_type.buffer_defaults) + if sys.version_info[0] < 3: + # Py 2.x enforces byte strings as keyword arguments ... + options = dict([ (name.encode('ASCII'), value) + for name, value in options.iteritems() ]) + self.type = PyrexTypes.BufferType(base_type, **options) return self.type -- 2.26.2