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 christian.heimes
Recipients Arfrever, christian.heimes, eric.snow, r.david.murray
Date 2012-10-08.02:26:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1349663174.54.0.0309527766137.issue16160@psf.upfronthosting.co.za>
In-reply-to
Content
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'>
History
Date User Action Args
2012-10-08 02:26:14christian.heimessetrecipients: + christian.heimes, Arfrever, r.david.murray, eric.snow
2012-10-08 02:26:14christian.heimessetmessageid: <1349663174.54.0.0309527766137.issue16160@psf.upfronthosting.co.za>
2012-10-08 02:26:14christian.heimeslinkissue16160 messages
2012-10-08 02:26:13christian.heimescreate