gh-152692: Fix annotationlib.type_repr() for bound built-in methods#152693
gh-152692: Fix annotationlib.type_repr() for bound built-in methods#152693tonghuaroot wants to merge 2 commits into
Conversation
…hods type_repr() returned a string naming a nonexistent module None -- e.g. type_repr([].append) == 'None.list.append' -- for bound built-in methods, whose __module__ is None. Return the qualified name when __module__ is None, as already done for the "builtins" module.
JelleZijlstra
left a comment
There was a problem hiding this comment.
This is incorrect for extension classes that are not in the builtins module.
>>> print(datetime.datetime.now().isoformat.__module__)
None
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
Good catch. When I have made the requested changes; please review again |
|
Thanks for making the requested changes! @sobolevn, @JelleZijlstra: please review the changes made to this pull request. |
type_repr()returned a string naming a nonexistent moduleNone-- e.g.type_repr([].append) == 'None.list.append'-- for bound built-in methods,whose
__module__isNone.Return the qualified name when
__module__isNone, as already done for the"builtins"module. This also covers C-accelerator functions such asrandom.random.annotations_to_stringandget_annotations(format=Format.STRING)are fixed transitively when anannotation value is such a method.