I don't see possible bug here. The first item of the tuple is always int or None. It's decrefing don't trigger executing user code. The second item of the tuple is decrefed when the refcount of the tuple is 2 and we own all references. The code triggered by decrefing the old item can't use the tuple (since its refcount is not 1 now), nor free the new index or new item (since we take the ownership of them). I think this patch is not needed.
Deferring decrefs as late as possible is a good practice, reducing the risk of bugs being introduced later. There have been other places where there were bugs that arose due to premature decreffing. I wrote the original code for enumerate, am the primary maintainer, and can make improvements to code organization as needed. Unless you think this change is broken, it should stay in.
This change is not broken. It is just redundant. If you are still inclined to apply this changes, I would suggest to factor out common code in enum_next_long and enum_next. > Oh, this change was not intended. I don't know how it occurred. Any reply changes the status from pending to open.