Skip to content

Issue 1001: fix last() when __reversed__ is None#1028

Merged
bbayles merged 1 commit intomore-itertools:masterfrom
inventshah:fix-1001
Jul 14, 2025
Merged

Issue 1001: fix last() when __reversed__ is None#1028
bbayles merged 1 commit intomore-itertools:masterfrom
inventshah:fix-1001

Conversation

@inventshah
Copy link
Copy Markdown
Contributor

Fixes #1001 by swapping hasattr with getattr.

We might consider a stronger check that iterable.__reversed__ is callable, but that seems unnecessary given expected usage.

@bbayles bbayles merged commit 7de169f into more-itertools:master Jul 14, 2025
6 checks passed
@inventshah inventshah deleted the fix-1001 branch July 14, 2025 14:51
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.

last() fails if __reversed__ is None, which is the case for the Mapping abc

2 participants