Ticket #228 (closed defect: fixed)

Opened 6 years ago

Last modified 5 years ago

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) (diff)

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

Changed 6 years ago by scoder

  • owner changed from somebody to scoder
  • status changed from new to assigned
  • description modified (diff)

Changed 6 years ago by scoder

  • description modified (diff)

Changed 6 years ago by scoder

  • priority changed from blocker to major
  • milestone changed from 0.11 to 0.11.1

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

Changed 5 years ago by robertwb

  • milestone changed from 0.11.1 to 0.11.2

Changed 5 years ago by dagss

  • milestone changed from 0.11.2 to 0.11.3

Changed 5 years ago by robertwb

  • milestone changed from 0.11.3 to 0.12

Changed 5 years ago by scoder

see also #346

Changed 5 years ago by scoder

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

Fix for Py3 is implemented here:

 http://hg.cython.org/cython-devel/rev/587be39d90f9

Note: See TracTickets for help on using tickets.