mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
[3.10] bpo-46333: Honor module
parameter in ForwardRef (GH-30536) (GH-31379)
The `module` parameter carries semantic information about the forward ref.
Forward refs are different if they refer to different module even if they
have the same name. This affects the `__eq__`, `__repr__` and `__hash__` methods.
Co-authored-by: Andreas Hangauer <andreas.hangauer@siemens.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
(cherry picked from commit 6e7b813195
)
Co-authored-by: aha79 <34090357+aha79@users.noreply.github.com>
Automerge-Triggered-By: GH:JelleZijlstra
This commit is contained in:
parent
d4e4ef107a
commit
a17d59a6df
4 changed files with 20 additions and 2 deletions
|
@ -705,10 +705,11 @@ class ForwardRef(_Final, _root=True):
|
|||
if self.__forward_evaluated__ and other.__forward_evaluated__:
|
||||
return (self.__forward_arg__ == other.__forward_arg__ and
|
||||
self.__forward_value__ == other.__forward_value__)
|
||||
return self.__forward_arg__ == other.__forward_arg__
|
||||
return (self.__forward_arg__ == other.__forward_arg__ and
|
||||
self.__forward_module__ == other.__forward_module__)
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.__forward_arg__)
|
||||
return hash((self.__forward_arg__, self.__forward_module__))
|
||||
|
||||
def __repr__(self):
|
||||
return f'ForwardRef({self.__forward_arg__!r})'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue