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.

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

2222 name=orig.__name__,
2323 argdefs=getattr(orig, "__defaults__", None),
2424 closure=getattr(orig, "__closure__", None))
25+ if hasattr(orig, "__kwdefaults__"):
26+ ret.__kwdefaults__ = orig.__kwdefaults__
2527 if copy_dict:
2628 ret.__dict__.update(orig.__dict__)
2729 return ret

The check that tells the two apart

failpass·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