Ticket #166 (closed defect: fixed)

Opened 20 months ago

Last modified 16 months ago

cdef'd list raises wrong exception on append when list is None

Reported by: hoytak Owned by: scoder
Priority: minor Milestone: 0.12
Component: Code Generation Keywords:
Cc:

Description

Hello,

In cython-devel version 1497, I think a check for None is not being inserted for list.append(). The following code

def crash():
    cdef list l = None

    l.append(2)

raise the following exception:

In [4]: list_as_none.crash()
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)

/home/hoytak/workspace/cython-tests/list_as_none/<ipython console> in <module>()

/home/hoytak/workspace/cython-tests/list_as_none/list_as_none.so in list_as_none.crash (list_as_none.c:219)()
      1 def crash():
      2     cdef list l = None
      3
----> 4     l.append(2)

SystemError: Objects/listobject.c:255: bad argument to internal function

I believe this should be something indicating that l is None.

Change History

Changed 20 months ago by scoder

  • milestone changed from wishlist to 0.11

Changed 19 months ago by scoder

I guess this is a general problem with the "builtin-type argument to C-API function" mapping. We always need an additional None check when we optimise this.

Changed 18 months ago by robertwb

  • milestone changed from 0.11 to 0.11.1

Changed 17 months ago by robertwb

OTOH, is this any different than calling a cdef method on a extension class variable containing None?

Changed 16 months ago by scoder

  • milestone changed from 0.11.1 to 0.12

Yes, because you are not calling a cdef method. You would normally expect a TypeError?, not a SystemError? for this. The reason why you get a SystemError? is an implementation detail of Cython.

This should be fixed in the Optimize.OptimizeBuiltinCalls? transform (currently in cython-unstable), therefore moving it to 0.12.

Changed 16 months ago by scoder

  • owner changed from somebody to scoder
  • status changed from new to assigned

Runtime None check implemented here:

 http://hg.cython.org/cython-unstable/rev/4495287d2fdb

Changed 16 months ago by scoder

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.