[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

Rick Teachey report at bugs.python.org
Mon Mar 26 12:57:12 EDT 2018


Rick Teachey <ricky at teachey.org> added the comment:

Eric, looking at the PR; note that if you do this for the __set_name__ check:

    if inspect.ismethoddescriptor(self.default):

...an object like the one below will not get its __set_name__ called, even though PEP 487 says it should:

class D:
	def __set_name__(self, o, n):
		self.name = n

class C:
	d: int = D()

if __name__ == "__main__":
	print(f"C.d.name = {C.d.name}") # __set_name__ was called
	assert inspect.ismethoddescriptor(C.d) # Error

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33141>
_______________________________________


More information about the Python-bugs-list mailing list