Py3 fix
authorStefan Behnel <scoder@users.berlios.de>
Fri, 21 Aug 2009 07:50:05 +0000 (09:50 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 21 Aug 2009 07:50:05 +0000 (09:50 +0200)
Cython/Compiler/Buffer.py
Cython/Compiler/Nodes.py

index bfcedc9cc2fc567dcfb6afa27e108f1dfb56ea42..b297ad152dae69c284025c1b6e1dae2902aef326 100644 (file)
@@ -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)
index 1c816692aaed3e8ca2506aa50127436845d4bb62..da818675a7f3eed246f32a3b2555f6f378e6656f 100644 (file)
@@ -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