-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-144475: Fix a heap buffer overflow in partial_repr #144571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
brijkapadia
wants to merge
231
commits into
python:main
from
brijkapadia:fix-functools_partial_repr_bug
Closed
Changes from 20 commits
Commits
Show all changes
231 commits
Select commit
Hold shift + click to select a range
b0ffe74
Fix a heap buffer overflow in partial_repr
brijkapadia 7c1ed7e
📜🤖 Added by blurb_it.
blurb-it[bot] 2723186
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
brijkapadia 239c40d
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
brijkapadia e53d7e9
Apply suggestion from @picnixz
brijkapadia 661af78
Updates to partial_repr
brijkapadia 5ce61d9
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
brijkapadia 92eb6ea
Added test and fixed bug in functions/keword arguments
brijkapadia 5bf71f9
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
brijkapadia cf63067
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
brijkapadia 838c8b1
Merge branch 'main' into fix-functools_partial_repr_bug
brijkapadia cb25ea5
improved goto logic
brijkapadia e18f2ad
Merge branch 'main' into fix-functools_partial_repr_bug
brijkapadia f1dc06f
Merge branch 'main' into fix-functools_partial_repr_bug
brijkapadia 30d39f4
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
brijkapadia a004007
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
brijkapadia 24307a2
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
brijkapadia 192ff1e
Update 2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
brijkapadia 715949f
Merge branch 'main' into fix-functools_partial_repr_bug
brijkapadia a196de4
goto rename with error
brijkapadia ac8ff42
Merge remote-tracking branch 'upstream/main' into fix-functools_parti…
brijkapadia 0a102fd
test update
brijkapadia 464fd67
gh-144490: Fix mimalloc debug build for C++ (#144620)
yoney 39ebd56
gh-144652: Support Windows exit status in support get_signal_name() (…
vstinner 6aa0be4
gh-143650: Fix importlib race condition on import failure (GH-143651)
gpshead f074be1
Clarify the docs for `args` in asyncio callbacks (#143873)
akx 7f4312b
gh-134584: Optimize `_BINARY_OP_SUBSCR_LIST_SLICE` (GH-144659)
Sacul0457 4601e9c
gh-144629: Add test for the PyFunction_GetAnnotations() function (#14…
nybblista 9784156
gh-141563: Add missing cast to _PyDateTime_IMPORT() (#144667)
vstinner fceed06
gh-141563: Don't test datetime.h with the limited C API (#144673)
vstinner 00c0a4a
gh-133879: Copyedit "What's new in Python 3.15" (#144661)
hugovk 227e8f4
gh-141563: Fix test_cext on Windows (#144677)
vstinner f1dcc5b
gh-141563: Fix test_cppext on macOS (#144685)
vstinner a343e30
docs: profiling.sampling: Fix sampling-rate default value description…
dubek 25648d5
gh-138122: Add sampling profiler visualisation to docs (#142772)
lkollar 1dc38d7
gh-140421: Disable perf trampoline on older macOS (#144647)
jmroot f67040f
gh-106318: Improve str.rstrip() method doc (#143893)
adorilson 014e849
Python 3.15.0a6
hugovk 540eb0a
Post 3.15.0a6
hugovk cd82c3b
gh-144321: Fix named tuple bug when input is a non-sequence iterable …
brijkapadia cac6fed
gh-142518: Define lock-free and per-object lock (#144548)
lysnikolaou 5c2a6df
Docs: remove links of modules to themselves (#144695)
nedbat c7ebadd
gh-142518: Document thread-safety guarantees of dict operations (#144…
lysnikolaou 25ce2a3
gh-144639: Ruff: target Python 3.14 syntax in `Lib/test` (#144656)
hugovk 2ce2e1e
gh-143300: implement `PyUnstable_SetImmortal` for marking objects as …
kumaraditya303 9c6c44f
Fix typos and grammar errors across documentation (#144709)
him2him2 974cbd7
gh-141563: Enable test_cppext internal C API tests on macOS (#144711)
vstinner 4dbc464
gh-84424: Use numeric_changed for UCD.numeric (GH-19457)
wmeehan 48c7b6b
gh-144675: update to WASI SDK 30 (#144676)
rvolosatovs e390afc
gh-142349: Implement PEP 810 - Explicit lazy imports (#142351)
pablogsal 92a865c
gh-106318: Fix incorrectly rendered code block in `str.isalnum()` doc…
adorilson dae3dda
gh-142349: Fix build errors from PEP 810 (#144726)
pablogsal fd4cc86
Add missing step to `Modules/expat/refresh.sh` instructions (GH-144719)
StanFromIreland c891299
gh-57095: Add note about input splitting in `datetime.*.strptime` (GH…
StanFromIreland a46495c
gh-142349: Fix refcount corruption in lazy import specialization (#14…
pablogsal bc2cc21
gh-144285: Improve `AttributeError` attribute suggestions (#144299)
johnslavik 8eaeb52
gh-138744: Upgrade Windows to 2025 in GitHub Actions (#144682)
vstinner 2c45bbe
gh-121617: Include <string.h> for Py_CLEAR() macro (#144666)
vstinner 669df2e
gh-80667: Fix case-sensitivity of some Unicode literal escapes (GH-10…
SnoopJ 66741f7
gh-135906: Test more internal headers in test_cext/test_cppext (#144751)
vstinner 05c706a
gh-143916: Allow HTAB in wsgiref header values
sethmlarson 13d9e3c
gh-144706: Warn against using synchronization primitives within signa…
robsdedude 8679922
gh-143637: Fix re-entrant mutation of ancillary data in socket.sendms…
priyanshu2282-cyber e3947e0
gh-144787: [tests] Allow TLS v1.2 to be minimum version (GH-144790)
colin-pm 0e71002
gh-144551: Update Windows builds to use OpenSSL 3.0.19 (GH-144793)
zware 5a3ecca
gh-144551: Update CI to use latest OpenSSL versions (GH-144794)
zware 5671719
gh-136672: Docs: Move parts of Enum HOWTO to API Docs (GH-139176)
RafaelWO fa90ebd
gh-144551: Update Windows builds to use OpenSSL 3.5.5 (GH-144796)
zware 12cc209
gh-144551: Update OpenSSL version references in Mac/BuildScript/ (GH-…
zware 10845cb
gh-144551: Update various CI jobs to OpenSSL 3.5 (GH-144808)
zware a12a0e0
gh-138912: Improve MATCH_CLASS opcode performance (GH-138915)
cdce8p 0815f74
gh-144766: Fix a crash in fork child process when perf support is ena…
yilei 9835ec6
remove unused _PyFunction_LookupByVersion (GH-144814)
chris-eibl e0b5abb
fix warnings in jit builds (GH-144817)
chris-eibl 178ea28
gh-144822: remove redundant decref in `codegen.c` (#144823)
benediktjohannes 0b1ce1d
gh-144759: Fix undefined behavior from NULL pointer arithmetic in lex…
raminfp c986a1a
add whatsnew entry for `PyUnstable_SetImmortal` and `PyDatetime_IMPOR…
kumaraditya303 4e1ea49
gh-142349: Add CODEOWNERS for lazy imports (#144840)
pablogsal 78f8efd
Format CODEOWNERS file (#144842)
pablogsal baa8a32
gh-144727: Add test for circular lazy import crash (#144727) (#144838)
pablogsal 22df6fe
gh-86519: Add prefixmatch APIs to the re module (GH-31137)
gpshead a70fbd9
gh-144833: Fix use-after-free in SSL module when SSL_new() fails (GH-…
raminfp 4ac371e
gh-144551: Update Android builds to use OpenSSL 3.0.19 (GH-144864)
zware d1fd1e7
gh-144551: Update iOS builds to use OpenSSL 3.0.19 (GH-144865)
zware 74ad485
gh-80667: Fix Tangut ideographs names in unicodedata (GH-144789)
serhiy-storchaka c7391db
bpo-32234: Allow mailbox instances as context managers (GH-4770)
sblondon 1fd0d45
gh-144878: Gate PEP 810 builtins in xpickle compat tests (#144889)
pablogsal 9edaade
gh-140715: Add `%D` format code support to `strptime()` (GH-144819)
jyalim b5bb2b7
gh-142349: Fix ast.unparse for lazy import statements (#144893)
pablogsal cb8ce7e
gh-144782: Make sure that ArgumentParser instances are pickleable (#1…
mauvilsa a13c261
gh-143637: Fix test_socket.test_sendmsg_reentrant_ancillary_mutation(…
vstinner 1044beb
gh-141510, PEP 814: Add built-in frozendict type (#144757)
vstinner 825a1c4
Enable CPU tests on default ARM build (#144743)
hugovk a32ba67
gh-141510: Update mp_length of frozendict to use non atomic operation…
corona10 13c721f
gh-141510: Remove unncessary lock holding for frozendict repr (gh-144…
corona10 3f3bd45
gh-144438: Fix false sharing between QSBR and tlbc_index (gh-144554)
colesbury dc4da97
gh-141510: Optimize hash(frozendict) (#144919)
vstinner eaf0368
gh-141510: Change repr(frozendict) for empty dict (#144921)
vstinner b5d4f89
gh-141510: Update `test_xpickle` for `frozendict` (#144927)
StanFromIreland c2b8cdf
gh-141510: Optimize {frozen}dict.fromkeys for frozendict (gh-144915)
corona10 d144505
gh-141510: Mention frozendict in dict documentation (#144934)
vstinner 839d770
gh-144914: use `mimalloc` for raw allocations on free-threading (#144…
kumaraditya303 50fb255
Move CODEOWNERS rule from devguide (GH-144924)
StanFromIreland 80f9b37
Docs: Remove unnecessary entry from `nitpick_ignore` (GH-144933)
StanFromIreland 2599349
Docs: an "improve this page" feature (#144939)
nedbat 80e9d32
gh-142224: unicodedata: support bidi classes for unassigned code poin…
StanFromIreland 75d1eaa
gh-144882: Optimize name tables in unicodedata by excluding names der…
serhiy-storchaka 731e4f9
gh-144386: Update equivalent code for "with", "async with" and "async…
serhiy-storchaka ca156b5
gh-135573: Make pickled lists, sets and dicts a tiny bit smaller (GH-…
serhiy-storchaka 583b9d7
gh-141510: Implement copy and deepcopy for frozendict (#144905)
eendebakpt 37e54b1
gh-140652: Fix a crash in _interpchannels.list_all() after closing a …
serhiy-storchaka 9891e9c
gh-141984: Reword and reorganize the first part of Atoms docs (GH-144…
encukou 32e22ac
gh-124748: Fix handling kwargs in `WeakKeyDictionary.update()` (#124783)
rigilfanov 2fe8083
Datetime: Tidy up docs (GH-144720)
StanFromIreland 208727d
gh-141510: Add frozendict fast-path to the set type (#144912)
vstinner 77fe2c7
gh-141510: Add can_modify_dict() in dictobject.c (#144955)
vstinner c43117e
gh-141510: Fix frozendict.fromkeys() for subclasses (#144952)
vstinner e19d9ae
gh-144763: Don't detach the GIL in tracemalloc (#144779)
vstinner f223393
gh-135573: Add tests for pickle opcodes with wrong types (GH-144950)
serhiy-storchaka ed328b5
gh-141510: Update specializer to support frozendict (gh-144949)
corona10 64c7efd
gh-141510: Fix frozendict.fromkeys() for dict subclasses (#144962)
vstinner b7da1f0
gh-141510: Replace MappingProxyType with frozendict (#144904)
vstinner 36385c8
gh-144969: Document that the free threading GC can change ob_tid (#14…
colesbury 5a4cbbd
gh-144888: Don't invalidate executors during function deallocation (#…
Fidget-Spinner b2c405d
Remove unused :platform: in module's docs (GH-144988)
StanFromIreland b2a1b6f
GH-144651: Optimize the new uops added when recording values during t…
markshannon 8174d4e
GH-144679: When building with VS 2026 on Windows, use PlatformToolset…
chris-eibl eb40599
gh-141510: Update Whats News for frozendict (gh-144961)
corona10 749f404
gh-144702: Use standard terminology in class pattern error message (#…
sharkdp 49f6013
gh-141510: Update ftscalingbench to support frozendict (gh-144999)
corona10 6fdfc43
gh-84393: Remove AIX workaround: re-enable posix_fadvise and f_alloca…
encukou d51318d
gh-139899: Introduce MetaPathFinder.discover and PathEntryFinder.disc…
FFY00 863dbc2
GH-134872: add ModuleNotFoundError suggestions (#142512)
FFY00 60d6b7e
GH-144679: MSVC tailcall CI no longer needs to specify PlatformToolse…
chris-eibl fed90e6
`compute-changes.py`: Fix & test `process_changed_files()` (#144674)
StanFromIreland e63f2ea
GH-144679: Switch to windows-2025-vs2026 build image in GitHub Action…
chris-eibl 21ab5a3
gh-144156: Fix email header folding concatenating encoded words (#144…
robsdedude c155613
gh-100239: Use ``PyFloat_AS_DOUBLE`` and `_PyLong_IsZero`` in the flo…
chris-eibl 0ddf0ff
Add myself as a codeowner for the C API documentation (#145017)
ZeroIntensity 8e04b79
gh-144986: Fix memory leak in atexit.register() (#144987)
ashm-dev a77e9d5
gh-141510: Document ParameterizedMIMEHeader.params change (#145003)
vstinner f0cf076
Correct MAX_N in Lib/zipfile ZipExtFile (GH-144973)
jberg5 8379f32
Docs: remove unneeded author attributions (#145002)
nedbat 7949f76
Update comments in `_strptime` module (GH-144979)
anton-ryzhov d301409
gh-141811: Split up `init.rst` into multiple pages (GH-144844)
ZeroIntensity 5c858b3
Simplify summary tables in the itertools docs (gh-145050)
rhettinger 231b811
gh-144981: Make PyUnstable_Code_SetExtra/GetExtra thread-safe (#144980)
yoney f507369
Fix errors in `CODEOWNERS` (#145049)
StanFromIreland 82db0b0
gh-144809: Make deque copy atomic in free-threaded build (gh-144966)
colesbury d59fe3a
gh-144748: Document 3.12 and 3.14 changes to `PyErr_CheckSignals` (GH…
ZeroIntensity 7f3d407
gh-145028: Fix blake2 tests in test_hashlib when it is missing due to…
tucif b9724c4
gh-144694: Fix re.Match.group() doc claiming [1..99] range limit (#14…
mohsinm-dev 2324277
gh-141510, PEP 814: Add frozendict support to pickle (#144967)
vstinner 502d21b
gh-143698: correctly check `scheduler` and `setpgroup` values for `os…
picnixz 87f4507
gh-141510, PEP 814: Add frozendict support to json (#144903)
vstinner ef867b3
gh-142516: fix reference leaks in `ssl.SSLContext` objects (#143685)
picnixz 2c9962b
gh-141226: Deprecate PEP-456 support for embedders (#141287)
picnixz 8a2e4dd
gh-141510: Fix test_xpickle for Python 3.14 and older (#145069)
vstinner d982910
gh-144285: Update *What's New* entry after GH-144299 (#145077)
johnslavik 5fb3e72
gh-145058: Add input validation to `_PyImport_LazyImportModuleLevelOb…
StanFromIreland c3796f2
Use `lazy` imports in `collections` (gh-145054)
rhettinger b58bb04
gh-141510: Fix copy.deepcopy() for recursive frozendict (#145027)
vstinner c6d8dd6
gh-141510: Test frozendict C API (#145081)
vstinner bb67255
gh-141510: Support frozendict in pprint (#144908)
vstinner 8816570
gh-141510: Check argument in PyDict_MergeFromSeq2() (#145082)
vstinner 7938d2f
gh-66802: Add `unicodedata.block()` function (#145042)
StanFromIreland a5ce713
gh-141510: Check argument in PyDict_Contains() (#145083)
vstinner b11c1a4
gh-141510: Test frozendict in test_capi.test_dict (#145084)
vstinner 0b326a5
gh-141510: Change dict_unhashable_type() error message for frozendict…
vstinner ff15c9e
gh-145076: Check globals type in __lazy_import__() (#145086)
vstinner d2bf310
gh-145092: Fix compiler warning for memchr() and wcschr() returning c…
heitbaum 6b7dc4d
Fix warnings on main (GH-145104)
chris-eibl a18d210
Refactor jit.yml (#144577)
savannahostrowski c06cdc2
gh-145064: Fix JIT assertion failure during CALL_ALLOC_AND_ENTER_INI…
cocolato 60c0567
gh-145131: difflib.Differ._fancy_replace performance (re-use ratio) (…
dg-pb 223990f
gh-144015: Add portable SIMD optimization for bytes.hex() et. al. (GH…
gpshead b19a59d
gh-145089: Fix frozendict constructor (#145128)
vstinner 4763dd7
gh-141004: Document `PyModuleDef_Type` (GH-145043)
ZeroIntensity fb04208
gh-144777: Fix data races in IncrementalNewlineDecoder (gh-144971)
colesbury d9f4bc7
Update argparse `suggest_on_error` code snippet in docs (#144985)
savannahostrowski 38e46f5
Add Savannah as `jit.yml` CODEOWNER (#145152)
savannahostrowski cbdc578
Indexing is more straight-forward (and faster) than unpacking (gh-145…
rhettinger f054382
gh-145118: Add `frozendict` support to `str.maketrans()` (gh-145129)
StanFromIreland 91c48a0
Update Python install manager docs (GH-145160)
zooba afa18e1
gh-145110: Fix cleaning of PGO builds in Windows build.bat script (GH…
chris-eibl 21f1eae
gh-110937: Document full public importlib.metadata.Distribution API (…
flying-sheep 605bbc2
`_struct.c`: Fix UB from integer overflow in `prepare_s` (GH-145158)
StanFromIreland eec5555
gh-101178: Fix possible integer overflow in Ascii85 encoder with wrap…
serhiy-storchaka 79b918d
gh-66305: Fix a hang on Windows in the tempfile module (GH-144672)
serhiy-storchaka 2231fac
gh-137335: Fix unlikely name conflicts for named pipes in multiproces…
serhiy-storchaka e2bf2ac
gh-143304: Fix ctypes.CDLL to honor handle parameter on POSIX systems…
Koolvansh07 5a269aa
Fix `inspect.Parameter` docstring on the `kind` attribute (GH-143541)
johnslavik 4b79957
gh-145122: Add _GUARD_NOS_ANY_DICT to prevent STORE_SUBSCR_DICT on fr…
corona10 1d94bd7
gh-143535: Dispatch on the second argument if generic method is insta…
johnslavik 26fbbfd
gh-88091: Fix unicodedata.decomposition() for Hangul Syllables (GH-14…
StanFromIreland bff02ce
gh-145187: Fix crash on invalid type parameter bound expression in co…
StanFromIreland 3afea78
gh-136677: Introduce executable specific linker flags to configure (#…
rueteh 08059f6
GH-145006: add ModuleNotFoundError hints when a module for a differen…
FFY00 e68a542
gh-47655: Add support for user data and detail of Tk events to tkinte…
mkiever 61f597d
GH-145000: Add a tool to record/check removed HTML IDs (#145001)
encukou fd0e4b4
gh-85809: Ensure shutil.make_archive accepts path-like objects in all…
tadejmagajna 0f4a555
Update status of blockers on combining pixi packges variant sources (…
FFY00 33ff6f6
gh-142518: Move thread safety sections into a new page (#144716)
lysnikolaou 19b8f2a
Fix "lazy from (...) import (...)" tests (#145213)
FFY00 15cab95
Fix compileall in lazy imports test data with bad syntax (#145221)
FFY00 d129eae
gh-145197: Fix JIT trace crash when recording function from cleared g…
cocolato 8c5b2d1
gh-144156: move news entry to Library (#145205)
robsdedude bf5ae6d
gh-145037: Fix Emscripten trampoline with emcc >= 4.0.19 (#145038)
hoodmane 3032154
gh-145202: Fix crash in unicodedata's GraphemeBreakIterator and Segme…
serhiy-storchaka 7e3e3c7
gh-106318: Add examples for str.rjust() method (#143890)
adorilson 9577f19
gh-144190: Clarify get_type_hints() instance behavior in docs (#144831)
iamrajhans 50beac6
gh-141510: Update `PyDict_Copy` documentation with note on `frozendic…
eendebakpt b9b2499
gh-144316: Fix missing exception in _remote_debugging with debug=Fals…
taegyunkim 0c4d940
gh-141510: support frozendict's in the C decimal module (gh-145165)
skirpichev 18910cc
gh-144872: fix heap buffer overflow `_PyTokenizer_ensure_utf8` (#144807)
AdamKorcz 26a469c
gh-142787: Handle empty sqlite3 blob slices (#142824)
abdoulrasheed 03ab030
Fix unlikely potential reference leak in _locale._getdefaultlocale (G…
serhiy-storchaka 6bedc25
gh-123853: Cleanup Windows 95 locale fallback support (#144738)
mokurin000 aca1c73
gh-145234: Normalize decoded CR in string tokenizer (#145281)
pablogsal 2ccbe65
gh-141004: Document missing type flags (GH-145127)
ZeroIntensity b1ae874
gh-144693: Clarify that `PyFrame_GetBack` does not raise exceptions (…
taegyunkim bbcb932
gh-145142: Make str.maketrans safe under free-threading (gh-145157)
VanshAgarwal24036 46a35ea
gh-145305: Update ocert.org URLs in docs from http to https (#145304)
indoor47 a1ecfd1
gh-76007: Deprecate `tarfile.version` (#145326)
StanFromIreland 07be84d
gh-145230: Update lockbench (gh-145231)
colesbury 4560c85
GH-144533: Use wasmtime's --argv0 to auto-discover sysconfig in WASI …
savannahostrowski 2958b3c
gh-145334: Make lazy import tests discoverable (#145336)
johnslavik e916488
gh-142927: Tachyon: Fix singular and plurals (#145329)
hugovk 0d13a6e
gh-145241: specialize SyntaxError for single trailing-comma with item…
pablogsal b17b37c
gh-145269: simplify bisect.bisect doc example (#145270)
ngoldbaum 8795fa5
Add Stan to 'Dates and times' reviewers (#145360)
StanFromIreland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -514,6 +514,70 @@ def test_partial_genericalias(self): | |
| self.assertEqual(alias.__args__, (int,)) | ||
| self.assertEqual(alias.__parameters__, ()) | ||
|
|
||
| # Issue 144475 | ||
| def test_repr_for_segfault(self): | ||
| g_partial = None | ||
|
|
||
| class Function: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need the Function class and cannot use simple function like |
||
| def __init__(self, name): | ||
| self.name = name | ||
|
|
||
| def __call__(self): | ||
| return None | ||
|
|
||
| def __repr__(self): | ||
| return f"Function({self.name})" | ||
|
|
||
| class EvilObject: | ||
| def __init__(self, name, is_trigger=False): | ||
| self.name = name | ||
| self.is_trigger = is_trigger | ||
| self.triggered = False | ||
|
|
||
| def __repr__(self): | ||
| if self.is_trigger and not self.triggered and g_partial is not None: | ||
| self.triggered = True | ||
| new_args_tuple = (None,) | ||
| new_keywords_dict = {"keyword": None} | ||
| new_tuple_state = (Function("new_function"), new_args_tuple, new_keywords_dict, None) | ||
| g_partial.__setstate__(new_tuple_state) | ||
| gc.collect() | ||
| return f"EvilObject({self.name})" | ||
|
|
||
| trigger = EvilObject("trigger", is_trigger=True) | ||
| victim = EvilObject("victim") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why |
||
|
|
||
| p = functools.partial(Function("old_function"), victim, victim=trigger) | ||
| g_partial = p | ||
| self.assertEqual(repr(g_partial),"functools.partial(Function(old_function), EvilObject(victim), victim=EvilObject(trigger))") | ||
|
|
||
| trigger.triggered = False | ||
| g_partial = None | ||
| p = functools.partial(Function("old_function"), trigger, victim=victim) | ||
| g_partial = p | ||
| self.assertEqual(repr(g_partial),"functools.partial(Function(old_function), EvilObject(trigger), victim=EvilObject(victim))") | ||
|
|
||
|
|
||
| trigger.triggered = False | ||
| p = functools.partial(Function("old_function"), trigger, victim) | ||
| g_partial = p | ||
|
|
||
| trigger.triggered = False | ||
| p = functools.partial(Function("old_function"), trigger=trigger, victim=victim) | ||
| g_partial = p | ||
| self.assertEqual(repr(g_partial),"functools.partial(Function(old_function), trigger=EvilObject(trigger), victim=EvilObject(victim))") | ||
|
|
||
| trigger.triggered = False | ||
| victim1 = EvilObject("victim") | ||
| victim2 = EvilObject("victim") | ||
| victim3 = EvilObject("victim") | ||
| victim4 = EvilObject("victim") | ||
| victim5 = EvilObject("victim") | ||
| p = functools.partial(Function("old_function"), trigger, victim1, victim2, victim3, victim4, victim=victim5) | ||
| g_partial = p | ||
| self.assertEqual(repr(g_partial),"functools.partial(Function(old_function), EvilObject(trigger), EvilObject(victim), EvilObject(victim), EvilObject(victim), EvilObject(victim), victim=EvilObject(victim))") | ||
|
|
||
|
|
||
|
|
||
| @unittest.skipUnless(c_functools, 'requires the C _functools module') | ||
| class TestPartialC(TestPartial, unittest.TestCase): | ||
|
|
||
6 changes: 6 additions & 0 deletions
6
Misc/NEWS.d/next/C_API/2026-02-07-16-37-42.gh-issue-144475.8tFEXw.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Fixed a bug in :func:`functools.partial` when calling :func:`repr` on a partial | ||
| object that could occur when the ``fn``, ``args``, or ``kw`` arguments are modified | ||
| during a call to :func:`repr`. Now, calls to :func:`repr` will use the original | ||
| arguments when generating the string representation of the partial object. | ||
| Subsequent calls will use the updated arguments instead. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.