Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cython generators clear the current exception #1731

Closed
jbradaric opened this issue Jun 12, 2017 · 1 comment · Fixed by #1832
Closed

Cython generators clear the current exception #1731

jbradaric opened this issue Jun 12, 2017 · 1 comment · Fixed by #1832

Comments

@jbradaric
Copy link

Cython version 0.25.2

To reproduce, create the following files:

generator_bug.pyx

def gen():
    yield 1

setup.py

from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize

ext_modules = [
    Extension('*', sources=['generator_bug.pyx'])
]

setup(
    name="generator_bug",
    ext_modules=cythonize(ext_modules),
    script_args=['build_ext'],
    options={'build_ext': {'inplace': True}}
)

Run python setup.py to build the extension module.

Run the following code from Python REPL:

from generator_bug import gen
try:
    1 / 0
except:
    for _ in gen():
        pass
    raise

The above code will not exit with a ZeroDivisionError, but a TypeError or RuntimeError, depending on whether the code is run using Python 2 or Python 3.

@scoder
Copy link
Contributor

scoder commented Aug 25, 2017

Should be fixed in #1832.

@scoder scoder added this to the 0.27 milestone Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants