Skip to content

gh-161970: Rename UserString.replace() parameter maxsplit to count - #161971

Open
Broyojo wants to merge 1 commit into
python:mainfrom
Broyojo:gh-161970-userstring-replace-count
Open

Broyojo wants to merge 1 commit into
python:mainfrom
Broyojo:gh-161970-userstring-replace-count

Conversation

@Broyojo

@Broyojo Broyojo commented Nov 14, 2026 •

Copy link
Copy Markdown

collections.UserString.replace() called its third parameter maxsplit, so UserString('aa').replace('a', 'b', count=1) raised TypeError even though str.replace() has accepted count as a keyword since 3.13. This renames it to count to match str.replace().

The existing test_count_keyword in Lib/test/string_tests.py called replace on str literals, so it never ran against UserString (or bytes/bytearray). It now goes through checkequal, which exercises every type that shares these tests.

Compatibility: a caller passing maxsplit= by keyword now gets TypeError. That name was never documented and str.replace() never accepted it, and I found no callers in the stdlib.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: βœ… Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
πŸ“ Code Review βœ… Completed 2026-11-14T00:28:09.854564Z 9d45abf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with πŸ‘€ while any review is running, comments if it has suggestions, and reacts with πŸ‘ once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant