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

StopIteration is silently ignored inside database transactions #17597

Open
MadLittleMods opened this issue Aug 21, 2024 · 0 comments
Open

StopIteration is silently ignored inside database transactions #17597

MadLittleMods opened this issue Aug 21, 2024 · 0 comments

Comments

@MadLittleMods
Copy link
Contributor

MadLittleMods commented Aug 21, 2024

Spawning from #17512 (comment),

If you accidentally cause a StopIteration exception to be thrown inside a transaction (txn stuff), nothing will appear in the logs even though everything blew up. It never reaches our try/except block that normally handles logging the exceptions.

You can run easily run into this by using something like next(iter(my_map.keys())) (to grab the first key in the iterable) where my_map is just an empty dictionary. But this problem is easily reproduced by just doing raise StopIteration directly.

Dev notes

Seems related to https://peps.python.org/pep-0479/ but that makes it seem like with that change (since Python 3.7), StopIteration shouldn't be silently ignored like it is now.

I'm guessing this is a bad interaction between the with context managers at various points and make_deferred_yieldable(...) swallowing it.

There have been more recent related issues around this like python/cpython#112182

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

No branches or pull requests

1 participant