[issue40523] Weakref proxy missing pass throughs for hash() and reversed()

2020-05-05 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40523] Weakref proxy missing pass throughs for hash() and reversed()

2020-05-05 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 96074de573f82fc66a2bd73c36905141a3f1d5c1 by Pablo Galindo in 
branch 'master':
bpo-40523: Add pass-throughs for hash() and reversed() to weakref.proxy objects 
(GH-19946)
https://github.com/python/cpython/commit/96074de573f82fc66a2bd73c36905141a3f1d5c1


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40523] Weakref proxy missing pass throughs for hash() and reversed()

2020-05-05 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
keywords: +patch
nosy: +pablogsal
nosy_count: 1.0 -> 2.0
pull_requests: +19261
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/19946

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40523] Weakref proxy missing pass throughs for hash() and reversed()

2020-05-05 Thread Raymond Hettinger


New submission from Raymond Hettinger :

from weakref import proxy

class Alpha:
def __len__(self):
return 3
def __reversed__(self):
return iter('cba')
def __hash__(self):
return hash('abc')

a = Alpha()

# Direct use of the instance works
print(len(a))
print(list(reversed(a)))
print(hash(a))

# Proxies can use the dunder methods directly
r = proxy(a)
print(r.__len__())
print(list(r.__reversed__()))
print(r.__hash__())

# Proxy fails for __reversed__ and __hash__
print(len(r), 'This succeeds')
try:
print(list(reversed(r)))
except TypeError:
print('reverse(r) failed')
try:
print(hash(r))
except TypeError:
print('hash(r) failed')

--
components: Library (Lib)
messages: 368197
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Weakref proxy missing pass throughs for hash() and reversed()
type: behavior
versions: Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com