[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Eric V. Smith
Eric V. Smith added the comment: Thanks for the bug report. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread miss-islington
miss-islington added the comment: New changeset c6147acd2ce5fa9e344f179b539f3b21b9ae1a6d by Miss Islington (bot) in branch '3.7': bpo-33141: Have dataclasses.Field pass through __set_name__ to any default argument. (GH-6260)

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread miss-islington
Change by miss-islington : -- pull_requests: +5987 ___ Python tracker ___

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Eric V. Smith
Eric V. Smith added the comment: New changeset de7a2f04d6b9427d568fcb43b6f512f9b4c4bd84 by Eric V. Smith in branch 'master': bpo-33141: Have dataclasses.Field pass through __set_name__ to any default argument. (GH-6260)

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Rick Teachey
Rick Teachey added the comment: Looks great to me. Thanks! -- ___ Python tracker ___ ___

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Eric V. Smith
Eric V. Smith added the comment: I've updated the PR. I left those lines in, and added a different test. After all, it does need to work with real descriptors. -- ___ Python tracker

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Rick Teachey
Rick Teachey added the comment: Yeah and I think lines 2709-2712 of TestDescriptors also needs removed. -- ___ Python tracker ___

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Eric V. Smith
Eric V. Smith added the comment: Yes, I noticed the same thing. I'll remove the test. -- ___ Python tracker ___

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Rick Teachey
Rick Teachey 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

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Eric V. Smith
Eric V. Smith added the comment: I don't expect there to be too much usage of Field objects, so I'm not so worried about it. If you can, try out the code in the PR. Thanks. -- ___ Python tracker

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Eric V. Smith
Change by Eric V. Smith : -- keywords: +patch pull_requests: +5984 stage: -> patch review ___ Python tracker ___

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Rick Teachey
Rick Teachey added the comment: I suppose one downside of that solution is __set_name__ will be called for every Field whether or not it is need. Probably can't be helped without major complications. -- ___ Python tracker

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Rick Teachey
Rick Teachey added the comment: Sounds like a relatively easy solution then. Hopefully it makes the beta 3 so I can use it immediately- thanks! -- ___ Python tracker

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Eric V. Smith
Eric V. Smith added the comment: Nick Coghlan suggested (on python-dev) to have Field implement __set_name__ and call through to the default value, if it exists. That approach seems to work fine. I'll generate a PR with tests sometime before today's release. --

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Rick Teachey
Rick Teachey added the comment: hmmm... if I check the C.d class attribute it seems to return the descriptor instance object (not a field object) before any C instances have been created. i guess this is just a part of how the dataclass implementation works. i didn't realize

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Eric V. Smith
Eric V. Smith added the comment: I suppose I could, when overwriting the class member, check for inspect.ismethoddescriptor and call __set_name__ myself. -- components: +Library (Lib) versions: +Python 3.8 ___ Python tracker

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-26 Thread Eric V. Smith
Eric V. Smith added the comment: That's a tough one. Because C.d is not set to a descriptor at type creation time (it's set to a Field object), the __set_name__ behavior is never invoked. It's when the @dataclass decorator is called that C.d is set to D().

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-25 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> eric.smith ___ Python tracker ___

[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

2018-03-25 Thread Rick Teachey
New submission from Rick Teachey : Summary: The descriptor `__set_name__` functionality (introduced in Python 3.6) does not seem to be working correctly for `dataclass.Field` objects with a default pointing to a descriptor. I have attached a file demonstrating the trouble.