Ezio Melotti added the comment: The issue seems to affect special attributes that can't be deleted. In Lib/unittest/mock.py:1329, patch() tried to delete the attribute, and then, if it doesn't exist, it restores the previous value. However some special attributes exist even after they are deleted, but their initial value is lost: >>> def foo(x:int=5, y:int=3): return x + y ... >>> foo.__defaults__ (5, 3) >>> del foo.__defaults__ >>> foo.__defaults__ >>> foo.__annotations__ {'y': <class 'int'>, 'x': <class 'int'>} >>> del foo.__annotations__ >>> foo.__annotations__ {} >>> foo.__qualname__ 'foo' >>> del foo.__qualname__ TypeError: __qualname__ must be set to a string object
---------- keywords: +easy nosy: +ezio.melotti, michael.foord stage: -> needs patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22138> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com