Issue1605023

classification
Title: items added to dict in __new__ on metaclass don't show up
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: cgroves Nosy List: cgroves, leouserz
Priority: normal Keywords:

Created on 2006-11-29.05:56:43 by cgroves, last changed 2007-01-03.03:44:57 by cgroves.

Messages
msg1347 (view) Author: Charlie Groves (cgroves) Date: 2006-11-29.05:56:43
__new__ isn't called on the metaclass of a Class when it's created.  This causes metaclass in test_descr to fail.
msg1348 (view) Author: Deleted User leouserz (leouserz) Date: 2006-12-22.18:55:51
this is a wicked problem.  I want to state this, that __new__ does appear to be called in the metaclass.  It seems though that __spam__ is not part of the class __dict__ when returned. 

Some things noticed:
1. Look at the PyNewWrapper for __new__ in PyType.  Notice that the getDict call return an empty Dictionary/PyStringMap.
2. Try accessing the dict of the PyType like so:
PyType pt = (PyType)(value returned from call)
System.out.println(pt.dict);

you should see __spam__ in it.

another odd thing, is that the name of the type returned is the metaclasses name.  Will continue investigation.

leouser
msg1349 (view) Author: Charlie Groves (cgroves) Date: 2006-12-24.02:45:55
I've actually looked at this a little bit.  __new__ is indeed called, but the dict passed in is ignored because the metatype is an instance of PyTypeDerived.  __spam__ is in the dict of the PyType, but because __dict__ is assignable in all Derived classes with a dict instance, the dict there in PyTypeDerived hides the one in PyType.  It's been a couple weeks since I touched this, but I should have some time in the coming week to get back to it and see if I had a suitable resolution.
msg1350 (view) Author: Charlie Groves (cgroves) Date: 2007-01-03.03:44:57
Fixed in r3040.  Letting PyTypeDerived use PyType's dict implementation lets the items filled in in __new__ come through.
History
Date User Action Args
2006-11-29 05:56:43cgrovescreate