[Cython] Minor bun in compile time constant handling

Nikita Nemkin nikita at nemkin.ru
Mon Mar 18 14:17:13 CET 2013


Hi,

Here:
https://github.com/cython/cython/blob/master/Cython/Compiler/Parsing.py#L708-L711
compile-time unicode and bytes values should be wrapped
with EncodedString and BytesLiteral respectively:

     elif isinstance(value, _unicode):
         return ExprNodes.UnicodeNode(pos, value=EncodedString(value))
     elif isinstance(value, _bytes):
         return ExprNodes.BytesNode(pos, value=BytesLiteral(value))

Otherwise attempts to use compile-time strings in Python context result
in errors like "AttributeError: 'unicode' object has no attribute  
'is_unicode'".

Best regards,
Nikita Nemkin


More information about the cython-devel mailing list