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 cjw296
Recipients Ramchandra Apte, cjw296, daniel.urban, docs@python, eric.araujo, ncoghlan, terry.reedy
Date 2013-02-18.08:14:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <5121D8AD.7010506@simplistix.co.uk>
In-reply-to <1360991112.28.0.120316277499.issue17179@psf.upfronthosting.co.za>
Content
Some background: I hit this problem when adding Python 3 compatibility 
to one of my libraries, where I had the following code:

from types import ClassType
...
class_ = ClassType(n, (sometype, ), dict(class_attr1='foo', 
class_attr2='bar')

It wasn't at all clear how to port this to Python 3, given that 
ClassType was gone.

types.new_class looks fair game, but the help is not exactly helpful:

new_class(name, bases=(), kwds=None, exec_body=None)
     Create a class object dynamically using the appropriate metaclass.

No indication there as to what type should be passed for kwds or exec_body.

I guessed and, by the sound of it, guessed wrong.
I'd certainly agree that the error message is very misleading.

cheers,

Chris
History
Date User Action Args
2013-02-18 08:14:21cjw296setrecipients: + cjw296, terry.reedy, ncoghlan, eric.araujo, daniel.urban, docs@python, Ramchandra Apte
2013-02-18 08:14:21cjw296linkissue17179 messages
2013-02-18 08:14:20cjw296create