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 daniel.urban
Recipients daniel.urban, eric.araujo, ncoghlan
Date 2012-04-18.20:50:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1334782233.71.0.211046947511.issue14588@psf.upfronthosting.co.za>
In-reply-to
Content
I've attached a patch with more tests. I simply copied and modified the tests about metaclass calculation and __prepare__ in test_descr.py, to create the tested classes with operator.build_class (and not the class statement).

Although, there is one thing I'm not sure I like about the API in the current patch: the dictionary corresponding to the keyword arguments of the class statement cannot be passed as keyword arguments. For example, I can't write this:

   C = operator.build_class('C', (A, B), metaclass=MyMeta)

I have to write this:

   C = operator.build_class('C', (A, B), {'metaclass': MyMeta})

(The reason for this is that the eval_body argument is the last.)
What would you think about the following signature for build_class?

   build_class(name, bases=(), eval_body=None, **kwargs)

The fist 3 argument could be positional only, and all keyword arguments would go into the dict. A downside is that the user would have to explicitly pass None as the 3rd argument, if they don't need an eval_body, but need keyword-arguments. Also, the 'bases' and the keyword arguments wouldn't be close to each other as in the class statement...
History
Date User Action Args
2012-04-18 20:50:33daniel.urbansetrecipients: + daniel.urban, ncoghlan, eric.araujo
2012-04-18 20:50:33daniel.urbansetmessageid: <1334782233.71.0.211046947511.issue14588@psf.upfronthosting.co.za>
2012-04-18 20:50:32daniel.urbanlinkissue14588 messages
2012-04-18 20:50:32daniel.urbancreate