[issue14588] PEP 3115 compliant dynamic class creation

2012-05-19 Thread Éric Araujo
Éric Araujo added the comment: Great doc patch. I think it would be worthwhile to backport it. -- ___ Python tracker ___ ___ Python-

[issue14588] PEP 3115 compliant dynamic class creation

2012-05-19 Thread Roundup Robot
Roundup Robot added the comment: New changeset befd56673c80 by Nick Coghlan in branch 'default': Close #14588: added a PEP 3115 compliant dynamic type creation mechanism http://hg.python.org/cpython/rev/befd56673c80 -- nosy: +python-dev resolution: -> fixed stage: -> committed/rejecte

[issue14588] PEP 3115 compliant dynamic class creation

2012-05-12 Thread Daniel Urban
Daniel Urban added the comment: Here is my first attempt at creating a pure Python version of the operator.build_class function (in my previous patch) as types.new_class. The three added functions (two private and one public) correspond to the following functions in my previous patch: types.n

[issue14588] PEP 3115 compliant dynamic class creation

2012-05-11 Thread Éric Araujo
Éric Araujo added the comment: Implementing in pure Python seems to have a lot of pros and no con to me. -- ___ Python tracker ___ __

[issue14588] PEP 3115 compliant dynamic class creation

2012-05-10 Thread Nick Coghlan
Nick Coghlan added the comment: Based on the python-dev thread [1], the proposed name for this API is now "types.new_class()". This parallels the existing imp.new_module() naming scheme and avoids various problems with the idea of using a static method on type itself (descriptors on type beh

[issue14588] PEP 3115 compliant dynamic class creation

2012-05-07 Thread Nick Coghlan
Nick Coghlan added the comment: In going to add documentation for your patch, I realised the operator module is not the right place for this. The "types" module actually seems like the most appropriate home, but that will require adding a _types module to back it. I'll post to python-dev to

[issue14588] PEP 3115 compliant dynamic class creation

2012-04-20 Thread Daniel Urban
Daniel Urban added the comment: I've attached the third patch with the eval_body -> exec_body change; explicitly passing the default (None) now also allowed. I also fixed a refleak (I think). -- Added file: http://bugs.python.org/file25292/operator_build_class_3.patch ___

[issue14588] PEP 3115 compliant dynamic class creation

2012-04-19 Thread R. David Murray
Changes by R. David Murray : -- nosy: +r.david.murray ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://ma

[issue14588] PEP 3115 compliant dynamic class creation

2012-04-19 Thread Nick Coghlan
Nick Coghlan added the comment: It occurs to me that, for naming consistency, the callback arg should be documented as "exec_body" rather than "eval_body". I'll try to get to a proper patch review this weekend. -- ___ Python tracker

[issue14588] PEP 3115 compliant dynamic class creation

2012-04-19 Thread Daniel Urban
Daniel Urban added the comment: Fair enough. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue14588] PEP 3115 compliant dynamic class creation

2012-04-18 Thread Nick Coghlan
Nick Coghlan added the comment: I thought about that, and I'd prefer a dedicated dictionary to avoid questions of name conflicts. Wrapping the keyword args in a dict() call is still pretty clean: C = operator.build_class('C', (A, B), dict(metaclass=MyMeta)) -- __

[issue14588] PEP 3115 compliant dynamic class creation

2012-04-18 Thread Daniel Urban
Daniel Urban added the comment: 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 no

[issue14588] PEP 3115 compliant dynamic class creation

2012-04-16 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +eric.araujo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyth

[issue14588] PEP 3115 compliant dynamic class creation

2012-04-16 Thread R. David Murray
Changes by R. David Murray : -- assignee: -> ncoghlan ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://m

[issue14588] PEP 3115 compliant dynamic class creation

2012-04-15 Thread Daniel Urban
New submission from Daniel Urban : As Nick Coghlan proposed [1, 2], there should be a way to dynamically create classes, which handles metaclasses correctly (see also issue1294232). Here is my first attempt at creating an operator.build_class method. It only includes very simple tests and no d