Skip to content

Remove dead stores to 'size' in UTF-8 decoder (unicodeobject.c) - #140637

Merged
sobolevn merged 1 commit into
python:mainfrom
ashm-dev:deadcode
Oct 27, 2025
Merged

sobolevn merged 1 commit into
python:mainfrom
ashm-dev:deadcode

Conversation

@ashm-dev

Copy link
Copy Markdown
Contributor

Summary

Remove two dead assignments to size after advancing s in the UTF-8 decoding paths. The decoding logic uses s and end for bounds; size is not read after these points. No functional changes.

Details

Affected functions: unicode_decode_utf8() and unicode_decode_utf8_writer()
After s += pos/decoded, previous code also did size -= pos/decoded, but the remaining input is tracked via s < end and passed to unicode_decode_utf8_impl(..., s, end, ...).
Eliminates dead-store/unused-but-set warnings from static analyzers/compilers.
Behavior and performance are unchanged.

Notes

  • No functional changes
  • No news entry (trivial cleanup)
  • OK to mark as skip issue / skip news

@StanFromIreland StanFromIreland added skip issue skip news type-refactor Code refactoring (with no changes in behavior) labels Oct 26, 2025

@cmaloney cmaloney left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks correct to me

@ashm-dev

Copy link
Copy Markdown
Contributor Author

@sobolevn Could you please review this PR?

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indeed, size is not used. Good catch!

@sobolevn
sobolevn merged commit 7d70a14 into python:main Oct 27, 2025
55 checks passed
@sobolevn sobolevn added awaiting merge needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Oct 27, 2025
@miss-islington-app

Copy link
Copy Markdown

Thanks @ashm-dev for the PR, and @sobolevn for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @ashm-dev for the PR, and @sobolevn for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @ashm-dev and @sobolevn, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 7d70a147f58edabc9691869a0e8b606c9c3ac184 3.13

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 27, 2025
…onGH-140637)

(cherry picked from commit 7d70a14)

Co-authored-by: Shamil <ashm.tech@proton.me>
@bedevere-app

bedevere-app Bot commented Oct 27, 2025

Copy link
Copy Markdown

GH-140658 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 27, 2025
@ashm-dev
ashm-dev deleted the deadcode branch October 27, 2025 08:57
@sobolevn

Copy link
Copy Markdown
Member

@ashm-dev please, take a look at 3.13 backport :)

sobolevn pushed a commit that referenced this pull request Oct 27, 2025
GH-140637) (#140658)

Remove dead stores to 'size' in UTF-8 decoder (unicodeobject.c) (GH-140637)
(cherry picked from commit 7d70a14)

Co-authored-by: Shamil <ashm.tech@proton.me>
@ashm-dev

Copy link
Copy Markdown
Contributor Author

@sobolevn There is no need to backport to 3.13, as I have verified that this size is not present there.

@vstinner vstinner removed the needs backport to 3.13 only security fixes label Oct 27, 2025
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge skip issue skip news type-refactor Code refactoring (with no changes in behavior)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants