[issue19359] reversed() does not work with weakref.proxy of sequences

2021-03-14 Thread Irit Katriel
Irit Katriel added the comment: On 3.10 the reversed_proxy_failure.py script fails with Traceback (most recent call last): File "/Users/iritkatriel/src/cpython/tmp.py", line 18, in reversed(weakref.proxy(foo)) # TypeError AttributeError: 'Foo' object has no attribute '__reversed__' --

[issue19359] reversed() does not work with weakref.proxy of sequences

2014-03-14 Thread Benjamin Peterson
Benjamin Peterson added the comment: afd62eb1692e wasn't a matter of speed, but a matter of correctness. Special methods should be looked up on the type on the instance as was done before. -- ___ Python tracker __

[issue19359] reversed() does not work with weakref.proxy of sequences

2014-03-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: Another possible idea is to introduce a "proxy protocol" (__proxy__ / tp_proxy) that would be used as a fallback by PyObject_LookupSpecial to fetch the lookup target, i.e.: def PyObject_LookupSpecial(obj, name): tp = type(obj) try: return getattr

[issue19359] reversed() does not work with weakref.proxy of sequences

2014-03-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: It would also perhaps be practical to have some kind of "proxy mixin" that everyone can re-use to avoid having to reimplement __special__ methods by hand. -- ___ Python tracker __

[issue19359] reversed() does not work with weakref.proxy of sequences

2014-03-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: I suppose Benjamin's commit is afd62eb1692e. Claudiu, that doesn't look like the best approach to me. Instead of hardcoding a weakref.proxy check in reversed(), why not implement __reversed__ on weakref.proxy? -- nosy: +pitrou ___

[issue19359] reversed() does not work with weakref.proxy of sequences

2014-03-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks for looking at this. Putting in a special case for weak references isn't the way to go. The problem is that _PyObject_LookupSpecial isn't working well with weakref proxies. A solution for reversed() could be to replace ``PyObject_GetAttrString(seq,

[issue19359] reversed() does not work with weakref.proxy of sequences

2014-03-13 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- priority: normal -> low type: behavior -> enhancement versions: +Python 3.5 -Python 2.7, Python 3.3 ___ Python tracker ___ _

[issue19359] reversed() does not work with weakref.proxy of sequences

2014-03-12 Thread Claudiu.Popa
Changes by Claudiu.Popa : Added file: http://bugs.python.org/file34376/issue19359.patch ___ Python tracker ___ ___ Python-bugs-list mailing li

[issue19359] reversed() does not work with weakref.proxy of sequences

2013-10-24 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue19359] reversed() does not work with weakref.proxy of sequences

2013-10-23 Thread Claudiu.Popa
Claudiu.Popa added the comment: Attached an attemptive patch. -- keywords: +patch nosy: +Claudiu.Popa Added file: http://bugs.python.org/file32322/reversed_proxy.patch ___ Python tracker ___

[issue19359] reversed() does not work with weakref.proxy of sequences

2013-10-23 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue19359] reversed() does not work with weakref.proxy of sequences

2013-10-23 Thread Austin Bingham
New submission from Austin Bingham: When passed a weakref.proxy to a legitimate sequence, reversed() throws a TypeError complaining that its argument isn't a sequence. Perhaps this is the expected behavior, but it's surprising to at least me and the few others I've spoken with about it. -