One function
LabeledContextDecorator in Suor/funcy
The author described this change as “Fix wrong label/stack setting when reentering print_(errors|durations)”. It counts as a record because the check below fails on the code as it stood at 6b057c477 and passes on e5e15486f, with nothing else changed between the two runs.
ProjectSuor/funcy
Fix saved2015-01-29
Sharing licenceBSD-3-Clause · LICENSE
Change size+4 −2
What the code was meant to do, written into the code itself as a docstring
A context manager which also works as decorator, passing call signature as its label.
The change
| 9 | 9 | def __call__(self, func): | |
| 10 | 10 | @wraps(func) | |
| 11 | 11 | def inner(*args, **kwargs): | |
| 12 | - | label = signature_repr(Call(func, args, kwargs)) | |
| 13 | - | cm = self.__class__(self.print_func, label) | |
| 12 | + | # Recreate self with a new label so that nested and recursive calls will work | |
| 13 | + | cm = self.__class__.__new__(self.__class__) | |
| 14 | + | cm.__dict__.update(self.__dict__) | |
| 15 | + | cm.label = signature_repr(Call(func, args, kwargs)) | |
| 14 | 16 | with cm: | |
| 15 | 17 | return func(*args, **kwargs) | |
| 16 | 18 | return inner |
The check that tells the two apart
fail→pass·tests/test_debug.py::test_print_errors
Check file tests/test_debug.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 it6b057c4771435e444ea9b78ee3c83e3cbb0df8e8
Broken version dated2015-01-29
Modulefuncy.debug
Units changedLabeledContextDecorator
Fingerprint9002531e833ab6ea
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 Suor/funcy
- 2021-05-09throttle