Ticket #170 (closed defect: fixed)

Opened 20 months ago

Last modified 16 months ago

better error when user-declared type conflicts with builtin type

Reported by: robertwb Owned by: robertwb
Priority: minor Milestone: 0.11.1
Component: Parsing Keywords:
Cc:

Description

The offending code

cdef extern from *:
    ctypedef class __builtin__.list [object PyListObject]:
        pass

cdef list foo = []

Proposed behavior

On Dec 18, 2008, at 3:53 AM, Muhammad Alkarouri wrote:

I suggested to report it according to your earlier suggestion, but I
would say the best way forward for Cython is to explicitly deprecate
the practice of declaring types that are defined by Cython. Say,
cython should fail with a kind of duplicate error or 'new definition
overrides cython built in' kind of message. The idea is that:

1. The will be less hairy code and more maintainable for cython developers.
2. For a cython user like me, such a failure would be clear enough to
modify the source in accordance.
3. Cython will probably grow more capabilities in types and other
optimizations in the future. These may replace user defined ones. If
users are used to this kind of change this will give Cython developers
more leeway in doing improvements in types and functions.

In short, I would fix that by giving a clearer error and also clearly
noting that in the documentation. The user should expect to have to
delete the offending duplicate type or function. Does that make sense?

Change History

Changed 17 months ago by scoder

  • milestone changed from wishlist to 0.11.1

Changed 16 months ago by robertwb

  • owner changed from somebody to robertwb

 http://hg.cython.org/cython-devel/rev/dc7359d237b9  http://hg.cython.org/cython-devel/rev/c22c5f879f26

For now it's a warning, because otherwise it's backwards incompatible. More work needs to be done to allow subclassing/attribute access from builtin types.

Changed 16 months ago by robertwb

  • status changed from new to closed
  • resolution set to fixed

Follow up at #258

Note: See TracTickets for help on using tickets.