One function
copy_function in mahmoud/boltons
The author described this change as “fix: make copy_function work with keyword-only defaults (#336)”. It counts as a record because the check below fails on the code as it stood at 0341ab3d7 and passes on c2b04b4cb, with nothing else changed between the two runs.
Projectmahmoud/boltons
Fix saved2023-04-21
Sharing licenceBSD-2-Clause · LICENSE
Change size+2 −0
What the code was meant to do, written into the code itself as a docstring
Returns a shallow copy of the function, including code object, globals, closure, etc. Args: orig (function): The function to be copied. Must be a function, not just any method or callable. copy_dict (bool): Also copy any attributes set on the function instance. Defaults to `True`.
The change
| 22 | 22 | name=orig.__name__, | |
| 23 | 23 | argdefs=getattr(orig, "__defaults__", None), | |
| 24 | 24 | closure=getattr(orig, "__closure__", None)) | |
| 25 | + | if hasattr(orig, "__kwdefaults__"): | |
| 26 | + | ret.__kwdefaults__ = orig.__kwdefaults__ | |
| 25 | 27 | if copy_dict: | |
| 26 | 28 | ret.__dict__.update(orig.__dict__) | |
| 27 | 29 | return ret |
The check that tells the two apart
fail→pass·tests/test_funcutils_fb_py3.py::test_copy_function_kw_defaults_py3
Check file tests/test_funcutils_fb_py3.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it0341ab3d79e6430c0e6a4149df9c92679988a534
Broken version dated2023-04-21
Moduleboltons.funcutils
Units changedcopy_function
Fingerprint979394f5df95aaff
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in mahmoud/boltons
- 2026-08-06Bits
- 2026-08-06JSONLIterator
- 2026-08-06tableutils: fix Table.to_text crashes on degenerate tables and headers
- 2026-07-18backoff_iter
- 2026-07-17singularize
- 2026-07-17fix(fileutils): accept os.PathLike in AtomicSaver