One function
_DescriptorBase in tkem/cachetools
The author described this change as “Fix #387: Handle obj=None case for inspection in _DescriptorBase.”. It counts as a record because the check below fails on the code as it stood at 8011b7194 and passes on 57d2e4813, with nothing else changed between the two runs.
Projecttkem/cachetools
Fix saved2026-03-05
Sharing licenceMIT · LICENSE
Change size+6 −1
What the code was meant to do, written into the code itself as a docstring
Descriptor base class implementing the basic descriptor protocol.
The change
| 16 | 16 | ||
| 17 | 17 | def __get__(self, obj, objtype=None): | |
| 18 | 18 | wrapper = self.Wrapper(obj) | |
| 19 | - | if self.__attrname is not None: | |
| 19 | + | if obj is None: | |
| 20 | + | # Return the wrapper itself without modification when accessed | |
| 21 | + | # through the class to support class-level introspection, such | |
| 22 | + | # as for mocking with autospec=True in unittest.mock. | |
| 23 | + | pass | |
| 24 | + | elif self.__attrname is not None: | |
| 20 | 25 | # replace descriptor instance with wrapper in instance dict | |
| 21 | 26 | try: | |
| 22 | 27 | # In case of a race condition where another thread already replaced |
The check that tells the two apart
fail→pass·tests/test_cachedmethod.py::AutospecTest::test_autospec_no_warnings
Check file tests/test_cachedmethod.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 it8011b71949e8d8d81a71359cca9477d67a2c9c0b
Broken version dated2026-03-02
Modulecachetools._cachedmethod
Units changed_DescriptorBase
Fingerprintada727b29342f643
Checked2026-08-17 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in tkem/cachetools
- 2026-07-22TLRUCache
- 2026-03-08Fix #218: Fix and properly document @cachedmethod.cache_key handling.
- 2024-08-18Fix #292, fix #205, fix #103: TTLCache.expire() returns iterable of expired (key, value) pairs.
- 2024-07-15mru_cache
- 2021-12-21Fix #159: Pass self to @cachedmethod key function.
- 2021-12-18TTLCache