GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-144475: Fix a heap buffer overflow in partial_repr by brijkapadia · Pull Request #144571 · python/cpython

Conversation

@brijkapadia

@brijkapadia brijkapadia commented Feb 7, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: heap-buffer-overflow in functools.partial.__repr__() #144475

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@brijkapadia
Fix a heap buffer overflow in partial_repr
b0ffe74
@brijkapadia
brijkapadia requested a review from rhettinger as a code owner February 7, 2026 16:19
@python-cla-bot

python-cla-bot Bot commented Feb 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

  • [email protected]
  • [email protected]
  • [email protected]

CLA not signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting review label Feb 7, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Feb 7, 2026
heap-buffer-overflow in functools.partial.__repr__() #144475
Closed
@bedevere-app

bedevere-app Bot commented Feb 7, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

blurb-it Bot and others added 3 commits February 7, 2026 16:37
@blurb-it
📜🤖 Added by blurb_it.
7c1ed7e
@brijkapadia
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
2723186
@brijkapadia
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
239c40d
@picnixz

picnixz commented Feb 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Please:

  • add regression tests and check that the test failed before your change
  • remove blank lines in NEWS
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Feb 7, 2026
View reviewed changes
Comment thread Modules/_functoolsmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Feb 7, 2026
View reviewed changes
Comment thread Modules/_functoolsmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Feb 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

By the way, @dr-carlos already suggested to open a PR. It is polite to ask them if they want to contribute themselves. As such, I'm going to close this one unless they are fine with you making the PR (we don't really want people "sniping" work of others)

dr-carlos reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brijkapadia

brijkapadia commented Feb 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. I missed that @dr-carlos suggested to fix it.

I’m happy to close this PR if @dr-carlos is already working on it.

dr-carlos reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brijkapadia @picnixz
Apply suggestion from @picnixz
e53d7e9
Co-authored-by: Bénédikt Tran <[email protected]>
@dr-carlos

dr-carlos commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for the feedback. I missed that @dr-carlos suggested to fix it.

I’m happy to close this PR if @dr-carlos is already working on it.

Hi, thanks for asking!
I'm happy for you to continue with the PR :)

brijkapadia reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dr-carlos
dr-carlos reviewed Feb 7, 2026
View reviewed changes
Comment thread Modules/_functoolsmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

brijkapadia and others added 3 commits February 7, 2026 16:39
@brijkapadia
Updates to partial_repr
661af78
@brijkapadia
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
5ce61d9
@brijkapadia
Added test and fixed bug in functions/keword arguments
92eb6ea
@brijkapadia

brijkapadia commented Feb 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Here are the changes I made:

  • I added a kw local pointer, as a similar segfault happens for keywords
  • I added an fn local pointer so that repr uses its original state when generating its final representation.
  • I got rid of the error goto and merged it with the done goto as I needed to decrement the reference count of fn, args, and kw, and I found that decrementing them in the done goto was the easiest.
    Update: I changed the goto logic to reduce repetitive calls to Py_DECREF
  • I added a test based on @Qanux's original code in issue heap-buffer-overflow in functools.partial.__repr__() #144475. I extended it to also check for changes in the fn and kw arguments.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brijkapadia and others added 9 commits February 7, 2026 21:17
@brijkapadia
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
5bf71f9
@brijkapadia
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
cf63067
@brijkapadia
Merge branch 'main' into fix-functools_partial_repr_bug
838c8b1
@brijkapadia
improved goto logic
cb25ea5
@brijkapadia
Merge branch 'main' into fix-functools_partial_repr_bug
e18f2ad
@brijkapadia
Merge branch 'main' into fix-functools_partial_repr_bug
f1dc06f
@brijkapadia
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
30d39f4
@brijkapadia
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
a004007
@brijkapadia
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
24307a2
serhiy-storchaka and others added 23 commits February 28, 2026 08:31
@serhiy-storchaka @brijkapadia
pythongh-145202: Fix crash in unicodedata's GraphemeBreakIterator and…
3032154
… Segment (pythonGH-145216)

Remove the tp_clear slots and make Segment members read-only.

Also add tests for reference loops involving GraphemeBreakIterator
and Segment.
@adorilson @brijkapadia
pythongh-106318: Add examples for str.rjust() method (python#143890)
7e3e3c7
@iamrajhans @brijkapadia
pythongh-144190: Clarify get_type_hints() instance behavior in docs (p…
9577f19
…ython#144831)
@eendebakpt @brijkapadia
pythongh-141510: Update PyDict_Copy documentation with note on `fro…
50beac6
…zendict` (pythonGH-145249)
@taegyunkim @brijkapadia
pythongh-144316: Fix missing exception in _remote_debugging with debu…
b9b2499
…g=False (python#144442)
@skirpichev @brijkapadia
pythongh-141510: support frozendict's in the C decimal module (python…
0c4d940
…gh-145165)
@AdamKorcz @brijkapadia
pythongh-144872: fix heap buffer overflow _PyTokenizer_ensure_utf8 (p…
18910cc
…ython#144807)
@abdoulrasheed @brijkapadia
pythongh-142787: Handle empty sqlite3 blob slices (python#142824)
26a469c
@serhiy-storchaka @brijkapadia
Fix unlikely potential reference leak in _locale._getdefaultlocale (p…
03ab030
…ythonGH-145250)

It occurs in a code which perhaps never executed.
@mokurin000 @brijkapadia
pythongh-123853: Cleanup Windows 95 locale fallback support (python#1…
6bedc25
…44738)

Closes python#123853
@pablogsal @brijkapadia
pythongh-145234: Normalize decoded CR in string tokenizer (python#145281
aca1c73
)
@ZeroIntensity @brijkapadia
pythongh-141004: Document missing type flags (pythonGH-145127)
2ccbe65
@taegyunkim @sergey-miryanov
@ZeroIntensity @brijkapadia
pythongh-144693: Clarify that PyFrame_GetBack does not raise except…
b1ae874
…ions (pythonGH-144824)

Co-authored-by: Sergey Miryanov <[email protected]>
Co-authored-by: Peter Bierma <[email protected]>
@VanshAgarwal24036 @brijkapadia
pythongh-145142: Make str.maketrans safe under free-threading (python…
bbcb932
…gh-145157)
@indoor47 Adam (indoor47) @brijkapadia
pythongh-145305: Update ocert.org URLs in docs from http to https (py…
46a35ea
…thon#145304)

Co-authored-by: Adam (indoor47) <[email protected]>
@StanFromIreland @hugovk @brijkapadia
pythongh-76007: Deprecate tarfile.version (python#145326)
a1ecfd1
Co-authored-by: Hugo van Kemenade <[email protected]>
@colesbury @brijkapadia
pythongh-145230: Update lockbench (pythongh-145231)
07be84d
Remove PyThread_type_lock (now uses PyMutex internally).

Add new benchmark options:
- work_inside/work_outside: control work inside and outside the critical section to vary contention levels
- num_locks: use multiple independent locks with threads assigned round-robin
- total_iters: fixed iteration count per thread instead of time-based, useful for measuring fairness
- num_acquisitions: lock acquisitions per loop iteration
- random_locks: acquire random lock each iteration

Also return elapsed time from benchmark_locks() and switch lockbench.py to use argparse.
@savannahostrowski @brijkapadia
pythonGH-144533: Use wasmtime's --argv0 to auto-discover sysconfig in…
4560c85
… WASI builds (python#145328)
@johnslavik @brijkapadia
pythongh-145334: Make lazy import tests discoverable (python#145336)
2958b3c
@hugovk @brijkapadia
pythongh-142927: Tachyon: Fix singular and plurals (python#145329)
e916488
@pablogsal @johnslavik @brijkapadia
pythongh-145241: specialize SyntaxError for single trailing-comma wit…
0d13a6e
…h item (python#145282)

Co-authored-by: Bartosz Sławecki <[email protected]>
@ngoldbaum @eendebakpt @brijkapadia
pythongh-145269: simplify bisect.bisect doc example (python#145270)
b17b37c
Co-authored-by: Pieter Eendebak <[email protected]>

---------

Co-authored-by: Pieter Eendebak <[email protected]>
@StanFromIreland @brijkapadia
Add Stan to 'Dates and times' reviewers (python#145360)
8795fa5
@brijkapadia
brijkapadia deleted the fix-functools_partial_repr_bug branch February 28, 2026 13:41
@hugovk
hugovk removed request for a team, berkerpeksag and freakboy3742 February 28, 2026 14:02
@brijkapadia brijkapadia mentioned this pull request Feb 28, 2026
gh-144475: Fix a heap buffer overflow in partial_repr #145362
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments
@picnixz picnixz picnixz left review comments
+2 more reviewers
@caje731 caje731 caje731 left review comments
@dr-carlos dr-carlos dr-carlos left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

20 participants

@brijkapadia @picnixz @dr-carlos @caje731 @serhiy-storchaka @StanFromIreland @yoney @vstinner @gpshead @akx @Sacul0457 @nybblista @hugovk @dubek @lkollar @jmroot @adorilson @lysnikolaou @nedbat @kumaraditya303
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.