Skip to content

Conversation

@rhettinger
Copy link
Contributor

@rhettinger rhettinger commented Sep 12, 2023

  • Fix bug where iter_index() did not work for list inputs.
  • Add test for list inputs.
  • Also add tests to make sure NaN handling is consistent between the two code paths.

📚 Documentation preview 📚: https://cpython-previews--109306.org.readthedocs.build/

@rhettinger rhettinger added type-bug An unexpected behavior, bug, or error docs Documentation in the Doc dir skip issue skip news needs backport to 3.12 only security fixes labels Sep 12, 2023
@rhettinger rhettinger merged commit f2a55fe into python:main Sep 12, 2023
@miss-islington
Copy link
Contributor

Thanks @rhettinger for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 12, 2023
…ythongh-109306)

(cherry picked from commit f2a55fe)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Sep 12, 2023

GH-109310 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Sep 12, 2023
@rhettinger rhettinger deleted the fix_iter_index_for_lists branch September 12, 2023 02:05
Comment on lines +1356 to +1358
>>> # Test list input. Lists do not support None for the stop argument
>>> list(iter_index(list('AABCADEAF'), 'A'))
[0, 1, 4, 7]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was not list input already tested above, in list(iter_index([0, x, x, y, 0], x))?

If you want a separate test for list which does not involve NaN, it is better to move this test upper, just after list(iter_index(iter('AABCADEAF'), 'A', 1, 7)).

Yhg1s pushed a commit that referenced this pull request Sep 12, 2023
…None. (gh-109306) (#109310)

Fix iter_index() to work with lists which do not support stop=None. (gh-109306)
(cherry picked from commit f2a55fe)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip issue skip news type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants