Message 80455 - Python tracker (original) (raw)

weakref.proxy needs to be fixed to delegate the unicode slot correctly.

from weakref import proxy "unicode" in dir(type(proxy(Exception))) False

That predicate must return true in order for the delegation to do the right thing (this is actually the case for all of the slots and pseudo-slots that can bypass getattribute on the instance object - it's just that most of them are already handled correctly).

This need to explicitly delegate all supported slots is the reason why weakref proxy instances add so many magic method stubs when compared to the actual interface of the underlying class:

len(set(dir(type(proxy(Exception)))) - set(dir(Exception))) 53