This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aleneum
Recipients aleneum, docs@python
Date 2021-06-28.14:15:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1624889705.43.0.546367758127.issue44523@roundup.psfhosted.org>
In-reply-to
Content
The documentation currently states:

> Proxy objects are not hashable regardless of the referent; this avoids a number of problems related to their fundamentally mutable nature, and prevent their use as dictionary keys. callback is the same as the parameter of the same name to the ref() function.

However, it seems with commit 96074de573f82fc66a2bd73c36905141a3f1d5c1 (https://github.com/python/cpython/commit/96074de573f82fc66a2bd73c36905141a3f1d5c1) hash/reversed pass throughs have been introduced that enable weakref.proxy to be used as a dictionary key. At least the following code fails with Python 3.8 but works with Python 3.9:

```
import weakref


class Model:
    pass


m = Model()
proxy = weakref.proxy(m)
ref = weakref.ref(m)
print(hash(m))
print(hash(ref))
print(hash(proxy))
```
History
Date User Action Args
2021-06-28 14:15:05aleneumsetrecipients: + aleneum, docs@python
2021-06-28 14:15:05aleneumsetmessageid: <1624889705.43.0.546367758127.issue44523@roundup.psfhosted.org>
2021-06-28 14:15:05aleneumlinkissue44523 messages
2021-06-28 14:15:05aleneumcreate