[Cython] Two minor bugs

Nikita Nemkin nikita at nemkin.ru
Sat Mar 2 07:52:44 CET 2013


I'm new to this list and to Cython internals.

Reporting two recently found bugs:

1. Explicit <bytes> cast fails unexpectedly:

        ctypedef char* LPSTR
        cdef LPSTR c_str = b"ascii"
        <bytes>c_str  # Failure: Python objects cannot be cast from  
pointers of primitive types

    The problem is CTypedefType not delegating can_coerce_to_pyobject() to  
the original type.
    (because BaseType.can_coerce_to_pyobject takes precedence over  
    Patch+test case and attached.

    Interestingly, implicit casts use a different code path and are not  

    There is potential for similar bugs in the future, because __getattr__
    delegation is inherently brittle in the presence of the base class  

2. This recently added code does not compile with MSVC:
    Interleaving declarations and statements is not allowed in C90...

Best Regards,
Nikita Nemkin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fixed-explicit-coercion-of-ctypedef-ed-C-types.patch
Type: application/octet-stream
Size: 2293 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20130302/2226d1fb/attachment.obj>

More information about the cython-devel mailing list