You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failed assertion in itertoolsmodule.c: itertools_count_impl for count(sys.maxsize) #126595
Python 3.13.0rc1+ (heads/3.13:bd29ce8509, Aug 29 2024, 15:30:15) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import maxsize
>>> from itertools import count
>>> c = count(maxsize)
>>> next(c)
9223372036854775807
>>> next(c)
9223372036854775808
>>> next(c)
9223372036854775809
So, I don't think this should be backported.
On another hand, we have an issue with repl. Continuing the above example:
Update: I found the issue. When the counter reaches PY_SSIZE_T_MAX, it does not set its long_cnt field. In particular, if you call repr() just after, the field will still be NULL (it's set by next only). I'm preparing the fix.
Activity
picnixz commentedon Nov 8, 2024
cc @rhettinger
skirpichev commentedon Nov 9, 2024
Note, that on non-debug builds there is no crash:
So, I don't think this should be backported.
On another hand, we have an issue with repl. Continuing the above example:
This seems to be fixed by pr.
picnixz commentedon Nov 9, 2024
I think we should still backport fixes for non-debug builds because people might want to use debug builds for themselves.
devdanzin commentedon Nov 9, 2024
Nice find! If we take it further, another assertion fails:
picnixz commentedon Nov 9, 2024
Ah the PR does not fix this second assertion on unicode objects. I'll work a bit more. Thanks for finding it.
picnixz commentedon Nov 9, 2024
Update: I found the issue. When the counter reaches
PY_SSIZE_T_MAX, it does not set itslong_cntfield. In particular, if you callrepr()just after, the field will still be NULL (it's set bynextonly). I'm preparing the fix.gh-126595: fix a crash when calling `itertools.count(sys.maxsize)` (#…
pythongh-126595: fix a crash when calling `itertools.count(sys.maxsiz…
[3.12] gh-126595: fix a crash when calling `itertools.count(sys.maxsi…
[3.13] gh-126595: fix a crash when calling `itertools.count(sys.maxsi…
picnixz commentedon Nov 12, 2024
Closing since completed and backported. Thank you all.
pythongh-126595: fix a crash when calling `itertools.count(sys.maxsiz…
pythongh-126595: fix a crash when calling `itertools.count(sys.maxsiz…