[issue17044] Implement PEP 422: Simple class initialisation hook

2018-01-27 Thread Nick Coghlan
Nick Coghlan added the comment: Indeed it should! Thanks for pointing that out :) -- resolution: -> out of date stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue17044] Implement PEP 422: Simple class initialisation hook

2018-01-27 Thread Cheryl Sabella
Cheryl Sabella added the comment: Since PEP 422 was withdrawn in favor of PEP 487, should this issue be closed? -- nosy: +csabella ___ Python tracker

[issue17044] Implement PEP 422: Simple class initialisation hook

2015-07-21 Thread Ethan Furman
Changes by Ethan Furman et...@stoneleaf.us: -- nosy: -ethan.furman ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17044 ___ ___ Python-bugs-list

[issue17044] Implement PEP 422: Simple class initialisation hook

2014-05-18 Thread Ethan Furman
Changes by Ethan Furman et...@stoneleaf.us: -- nosy: +ethan.furman ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17044 ___ ___ Python-bugs-list

[issue17044] Implement PEP 422: Simple class initialisation hook

2014-05-18 Thread Berker Peksag
Changes by Berker Peksag berker.pek...@gmail.com: -- versions: +Python 3.5 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17044 ___ ___

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-04-14 Thread Daniel Urban
Daniel Urban added the comment: I've attached a new patch. With this patch, type.__prepare__ has an optional keyword-only argument 'namespace', and returns it if it's specified. Also, __init_class__ is passed an argument: a mapping proxy of the mapping originally returned by __prepare__.

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-03-16 Thread Nick Coghlan
Nick Coghlan added the comment: Eric and I discussed this further this morning. We were interested in two main points: 1. When no custom namespace is used, we definitely shouldn't double the storage requirements for the class object 2. If a custom namespace is used, it would be nice to make it

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-03-16 Thread Eric Snow
Eric Snow added the comment: I'm fine with that. Would it make sense to have the signature of __init_class__ parallel meta.__init__(): __init_class__(cls, name, bases, namespace) or even __init_class__(cls, name, bases, ns, *, namespace=None, **kwds) --

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-03-14 Thread Nick Coghlan
Nick Coghlan added the comment: I hadn't noticed that type.__new__ copied the contents (it surprises me that it does both that *and* restricts the input type to a true dict instance). The Extending a class example should still work as shown, since the magic of that happens while the body of

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-03-14 Thread Eric Snow
Eric Snow added the comment: We should definitely have a way to expose the original dictionary from __prepare__(). Along with Nick's point, another reason is to allow class decorators to have access to that original, which is important to any use case that involves post-creation

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-03-14 Thread Eric Snow
Eric Snow added the comment: I've also opened #17421 for dropping the restriction on the namespace passed to the metaclass and #17422 for documenting that the passed namespace is copied into a new dict. -- ___ Python tracker rep...@bugs.python.org

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-03-14 Thread Eric Snow
Eric Snow added the comment: Given that, it is probably also better to revert the namespace keyword to accepting an instance rather than a factory function, since the copy operation after execution of the class body is automatic. Agreed. Of course, the related note is rendered superfluous.

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-03-14 Thread Nick Coghlan
Nick Coghlan added the comment: Oh, that's bizarre - the presence of __locals__ is a side effect of calling locals() in the class body. So perhaps passing the namespace as a separate __init_class__ parameter is a better option. -- ___ Python tracker

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-03-13 Thread Daniel Urban
Daniel Urban added the comment: I've looked into implementing the changes in the new version of the PEP. It seems, that currently type.__new__ copies the dict returned by __prepare__ (http://hg.python.org/cpython/file/55806d234653/Objects/typeobject.c#l2058). I think this means that some of

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-02-18 Thread Jesús Cea Avión
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17044 ___ ___ Python-bugs-list mailing list

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-02-17 Thread Daniel Urban
Daniel Urban added the comment: Thanks for the grammar correction, I've fixed it in the new patch. The new patch also adds object.__init_class__ (which is a no-op), to support cooperative multiple inheritance of __init_class__. (Adding type.__init_class__ was mentioned in the python-dev

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-02-17 Thread Daniel Urban
Changes by Daniel Urban urban.dani...@gmail.com: Removed file: http://bugs.python.org/file29097/pep422_4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17044 ___

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-02-17 Thread Daniel Urban
Changes by Daniel Urban urban.dani...@gmail.com: Added file: http://bugs.python.org/file29098/pep422_4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17044 ___

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-02-17 Thread Nick Coghlan
Nick Coghlan added the comment: Ah, I think I see your point - because __init_class__ is supposed to be a class method on instances of the metaclass, the anchor needs to be on object (the highest level instance of the default metaclass), not on type if we don't want super to behave strangely?

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-02-17 Thread Daniel Urban
Daniel Urban added the comment: Yes, if we would add a regular (instance) method __init_class__ to type, it could (probably) work for regular (non-meta) classes, but not for metaclasses. If a metaclass Meta wouldn't define __init_class__ itself, calling Meta.__init_class__() in

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-02-17 Thread Daniel Urban
Changes by Daniel Urban urban.dani...@gmail.com: Added file: http://bugs.python.org/file29102/pep422.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17044 ___

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-02-17 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17044 ___

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-02-11 Thread Florent Xicluna
Changes by Florent Xicluna florent.xicl...@gmail.com: -- nosy: +flox ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17044 ___ ___ Python-bugs-list

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-02-10 Thread Nick Coghlan
Nick Coghlan added the comment: I've belatedly applied the PEP update Daniel sent me, and added a reference to this issue from the PEP. The latest version of the patch looks very good to me, just one very minor nit with the phrasing in the docs. Specifically, it is better to replace like

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-01-30 Thread Daniel Urban
Daniel Urban added the comment: I'm attaching a new patch with some documentation and one additional test. -- Added file: http://bugs.python.org/file28912/pep422_3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17044

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-01-26 Thread Daniel Urban
New submission from Daniel Urban: The attached patch implements PEP 422 -- Simple class initialisation hook (__init_class__). It includes tests, but it doesn't include documentation yet. -- components: Interpreter Core, Library (Lib) files: pep422_1.patch keywords: needs review, patch

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-01-26 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17044 ___ ___

[issue17044] Implement PEP 422: Simple class initialisation hook

2013-01-26 Thread Daniel Urban
Daniel Urban added the comment: Thanks for the review Ezio! I've fixed the order of the arguments of assertEqual. Regarding your other comment: I agree that your code is shorter and clearer, but it doesn't do exactly the same thing. cls.__init_class__ can be None, and in that case, we should