[docs] [issue17179] Misleading error from type() when passing unknown keyword argument

Chris Withers report at bugs.python.org
Mon Feb 18 09:14:21 CET 2013


Chris Withers added the comment:

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

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17179>
_______________________________________


More information about the docs mailing list