Message172357
I have verified that the __init__ function isn't executed when SimpleNamespace is subclasses. I guess that's happening:
http://docs.python.org/py3k/c-api/typeobj.html?highlight=tp_init#PyTypeObject.tp_init
"If the tp_new function returns an instance of some other type that is not a subtype of the original type, no tp_init function is called; if tp_new returns an instance of a subtype of the original type, the subtype’s tp_init is called."
namespace_new always returns a namespace object no matter what. As namespace is not a subclass of the Foo (the other way around), the type check in type_call() fails and __init__ isn't called. The tp_new method needs a fix.
That looks all wrong to me:
>>> import types
>>> class SubNS(types.SimpleNamespace):
... pass
...
>>> SubNS.__new__(SubNS)
namespace()
That's about right:
>>> class SubStr(str):
... pass
...
>>> type(SubStr.__new__(SubStr))
<class '__main__.SubStr'> |
|
Date |
User |
Action |
Args |
2012-10-08 02:26:14 | christian.heimes | set | recipients:
+ christian.heimes, Arfrever, r.david.murray, eric.snow |
2012-10-08 02:26:14 | christian.heimes | set | messageid: <1349663174.54.0.0309527766137.issue16160@psf.upfronthosting.co.za> |
2012-10-08 02:26:14 | christian.heimes | link | issue16160 messages |
2012-10-08 02:26:13 | christian.heimes | create | |
|