deploy unicode.encode() optimisation also for 'bytes' provided encodings
authorStefan Behnel <scoder@users.berlios.de>
Wed, 14 Jul 2010 07:42:34 +0000 (09:42 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Wed, 14 Jul 2010 07:42:34 +0000 (09:42 +0200)
Cython/Compiler/Optimize.py

index 4a77e69406ba22d7a810bde4737ad379d5b84458..378b88a52907b00e0a0139939874e3ffacc25ad9 100644 (file)
@@ -2202,6 +2202,10 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
                 encoding = encoding_node.value
                 encoding_node = ExprNodes.BytesNode(encoding_node.pos, value=encoding,
                                                      type=PyrexTypes.c_char_ptr_type)
+            elif encoding_node.type is Builtin.bytes_type:
+                encoding = None
+                encoding_node = encoding_node.coerce_to(
+                    PyrexTypes.c_char_ptr_type, self.current_env())
             elif encoding_node.type.is_string:
                 encoding = None
             else:
@@ -2224,6 +2228,10 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
                     error_handling_node = ExprNodes.BytesNode(
                         error_handling_node.pos, value=error_handling,
                         type=PyrexTypes.c_char_ptr_type)
+            elif error_handling_node.type is Builtin.bytes_type:
+                error_handling = None
+                error_handling_node = error_handling_node.coerce_to(
+                    PyrexTypes.c_char_ptr_type, self.current_env())
             elif error_handling_node.type.is_string:
                 error_handling = None
             else: