Skip to content

[PR #14493/f976bb67 backport][9.0.x] Fix Code.getargs() treating co_flags bitmask values as counts#14535

Merged
nicoddemus merged 1 commit into
9.0.xfrom
patchback/backports/9.0.x/f976bb67b293cf358e2fbd0352638e2f5a9da8e0/pr-14493
May 30, 2026
Merged

[PR #14493/f976bb67 backport][9.0.x] Fix Code.getargs() treating co_flags bitmask values as counts#14535
nicoddemus merged 1 commit into
9.0.xfrom
patchback/backports/9.0.x/f976bb67b293cf358e2fbd0352638e2f5a9da8e0/pr-14493

Conversation

@patchback
Copy link
Copy Markdown

@patchback patchback Bot commented May 30, 2026

This is a backport of PR #14493 as merged into main (f976bb6).

CO_VARARGS (4) and CO_VARKEYWORDS (8) are bitmask flags, but they were used directly as increment values for the argument count via &. This caused co_varnames[:argcount] to slice beyond the actual arguments when the function body contained enough local variables.

Fix by wrapping the bitmask results in bool(), so they contribute at most 1 to the argcount.

Closes #14492

CO_VARARGS (4) and CO_VARKEYWORDS (8) are bitmask flags, but they were
used directly as increment values for the argument count via `&`.
This caused co_varnames[:argcount] to slice beyond the actual arguments
when the function body contained enough local variables.

Fix by wrapping the bitmask results in bool(), so they contribute
at most 1 to the argcount.

Closes #14492

(cherry picked from commit f976bb6)
@nicoddemus nicoddemus merged commit 76fefd0 into 9.0.x May 30, 2026
33 checks passed
@nicoddemus nicoddemus deleted the patchback/backports/9.0.x/f976bb67b293cf358e2fbd0352638e2f5a9da8e0/pr-14493 branch May 30, 2026 12:06
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.

2 participants