Skip to content

gh-161973: Don't modify the cached opcodes in difflib.SequenceMatcher.get_grouped_opcodes() - #162012

Open
Broyojo wants to merge 1 commit into
python:mainfrom
Broyojo:gh-161973-difflib-grouped-opcodes
Open

Broyojo wants to merge 1 commit into
python:mainfrom
Broyojo:gh-161973-difflib-grouped-opcodes

Conversation

@Broyojo

@Broyojo Broyojo commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

get_grouped_opcodes() trimmed the leading and trailing equal opcodes in place, on the list that get_opcodes() caches, so later get_opcodes() and get_grouped_opcodes() calls on the same matcher returned wrong results. It now works on a shallow copy; the tuples themselves are replaced rather than modified, so a copy of the list is enough. Added a regression test.

@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-14T17:10:35.320126Z 2cffa6d 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