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

Python exceptions within coroutines are reraised #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Python exceptions within coroutines are reraised #145

wants to merge 1 commit into from

Conversation

noahcgreen
Copy link

Fixes #144.
Currently if a lua coroutine calls Python code which raises an exception, a LuaError will be raised and the original exception will be lost. This isn't consistent with the behavior of non-coroutine code, which is to reraise the exception, and losing the original exception makes it very hard to debug lua coroutines.

A new unit test test_coroutine_reraises_python_error has been added.

Comment on lines +1297 to +1298
error = py_from_lua(runtime, L, 1)
if isinstance(error, BaseException):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I'm not sure it's intentional that this retrieves a Python exception object. Couldn't such an exception also end up on the Lua stack for other reasons? Meaning, could this run into false positives?

@synodriver
Copy link
Contributor

I've also meet the same problem, and I think the extra check should be at resume_lua_thread, right before raise_lua_error(thread._runtime, co, status), which only influence co.send itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lupa does not print Python error when using coroutines
3 participants