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.

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

1616
1717 def __get__(self, obj, objtype=None):
1818 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:
2025 # replace descriptor instance with wrapper in instance dict
2126 try:
2227 # In case of a race condition where another thread already replaced

The check that tells the two apart

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