Opened 6 years ago

Closed 5 years ago

#228 closed defect (fixed)

Exceptions get lost inside except blocks when shadowed by exceptions raised by Cython

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

Description (last modified by scoder)

This change

http://hg.cython.org/cython-devel/rev/24bb0456d787

breaks this code:

>>> try:
...     raise ValueError
... except:
...     print(sys.exc_info()[0] is ValueError or sys.exc_info()[0])
...     a = list(py_iterator())
...     print(sys.exc_info()[0] is ValueError or sys.exc_info()[0])
...     a = list(cy_iterator())
...     print(sys.exc_info()[0] is ValueError or sys.exc_info()[0])
True
True
True

The ValueError gets lost after the list(cy_iterator()) line, which raises a StopIteration that is caught by Python's list building code. The output of this doctest is

True
True
None

which is clearly unexpected.

Change History (8)

comment:1 Changed 6 years ago by scoder

  • Description modified (diff)
  • Owner changed from somebody to scoder
  • Status changed from new to assigned

comment:2 Changed 6 years ago by scoder

  • Description modified (diff)

comment:3 Changed 6 years ago by scoder

  • Milestone changed from 0.11 to 0.11.1
  • Priority changed from blocker to major

Here is a work around that moves the problem only into Py3, so that at least Py2 works as before.

http://hg.cython.org/cython-devel/rev/a0ebfe3b1cc2

comment:4 Changed 6 years ago by robertwb

  • Milestone changed from 0.11.1 to 0.11.2

comment:5 Changed 5 years ago by dagss

  • Milestone changed from 0.11.2 to 0.11.3

comment:6 Changed 5 years ago by robertwb

  • Milestone changed from 0.11.3 to 0.12

comment:7 Changed 5 years ago by scoder

see also #346

comment:8 Changed 5 years ago by scoder

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