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
itertools.groupby() can fail a C assert() #74532
Comments
This triggers an assert() failure on debug-mode Python (or a leak in release Python): from itertools import groupby
def f(n):
print("enter:", n)
if n == 5:
list(b)
print("leave:", n)
return n != 6
for (k, b) in groupby(range(10), f):
print(list(b)) With current trunk we get: python: ./Modules/itertoolsmodule.c:303: _grouper_next: Assertion `gbo->currkey == NULL' failed. |
Do you have a suggested fix? |
PR 1557 implements the simplest fix -- remove the assert and use Py_XSETREF() instead of simple assignment. Since the resulting code in _grouper_next() is identical to the code in groupby_next(), it was shared between these two functions. |
At first glance, the suggested PR looks fine. Unless there is a rush, I would like to hold-off spend more time thinking about bpo-30346 before moving forward with this one. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: