classification
Title: PEP 3115 patch
Type: Stage:
Components: Interpreter Core Versions: Python 3.0
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum
Priority: normal Keywords: patch

Created on 2007-03-15 00:09 by gvanrossum, last changed 2008-01-06 22:29 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
meta.patch gvanrossum, 2007-03-15 00:09 Preliminary patch; accepts new syntax but doesn't do anything with it yet.
meta.patch gvanrossum, 2007-03-15 21:06 More complete patch, implementing __build_class__ in Python.
meta.patch gvanrossum, 2007-03-15 21:53 New version, fixes _bsddb problem.
meta.patch gvanrossum, 2007-03-16 04:11 Version with __build_class__ in C.
meta.patch gvanrossum, 2007-03-16 15:53 Use LOAD_BUILD_CLASS opcode.
meta.patch gvanrossum, 2007-03-16 18:50 Add test_metaclass.py and fix __prepare__ signature bug.
meta.patch gvanrossum, 2007-03-16 20:07 More unittests; fix assert and don't mutate kwds.
meta.patch gvanrossum, 2007-03-16 20:27 Refactored __metaclass__ assignment.
meta.patch gvanrossum, 2007-03-16 23:12 Fix syntax error in pickletester.py (sorry).
Messages (10)
msg52224 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-03-15 00:09
A patch for PEP 3115 (metaclass syntax for Py3k).  This enables full [arglist] syntax in the class header, e.g.

class C(B1, B2, metaclass=MC, *more_bases, **kwds):
  pass
msg52225 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-03-15 21:06
Here's a new patch, which generates correct code for all variants of the class header syntax.

For now, I've implemented __build_class__ in Python; the built-in function by that name imports the build_class module and calls its build_class function.  (I'll later redo this in C.)

This is still rough; I didn't even delete the old BUILD_CLASS opcode.  But only a few unit tests fail (especially the ast and compiler tests).  There are no unit tests for the new functionality.  There is no documentation.

Failing tests:
    test_ast test_compiler test_ctypes test_descr test_grp test_pep292


File Added: meta.patch
msg52226 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-03-15 21:53
New version. Fixes problems with bsddb, removes dead declaration from bltinmodule.c, and updates outdated docs for MAKE_FUNCTION and MAKE_CLOSURE in opcode.h while I was at it.
File Added: meta.patch
msg52227 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-03-16 04:11
Here's a new version that implements __build_class__ in C.  It's still an ordinary built-in function loaded using LOAD_GLOBAL so you can play games with this; however I'd rather keep that an implementation detail and not a feature (unlike overriding __import__, which *is* a feature).

One thing that's missing is support for __metaclass__, either in the module, or in the class.  I don't want to support those (maybe the PEP should mention this), but we need a fixer for 2to3 to warn about this, at least (and to convert class C: __metaclass__ = M; ... into class C(metaclass=M): ...).

BTW, the test_grp failure mentioned earlier is bogus; that's an artefact of Google's LDAP.  Some more tests probably fail, but I'll worry about those later.
File Added: meta.patch
msg52228 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-03-16 15:53
New patch, gets rid of LOAD_LOCALS and BUILD_CLASS opcodes and adds LOAD_BUILD_CLASS opcode which avoids looking for __build_class__ in the globals; it only searches the builtins (like the IMPORT statement).  Though this is debatable.
File Added: meta.patch
msg52229 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-03-16 18:50
And another. This adds a unittest for the new build_class functionality, and fixes one bug (in the way __prepare__ was called) found this way.  BTW doctest rocks for this purpose.
File Added: meta.patch
msg52230 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-03-16 20:07
Fixed two bugs, with the help of (improved) test_metaclass.py:

- bug in symtable handling of keyword args that triggered an assert in debug mode
- bug in build_class that mutated the keyword args dict in place

I've got the feeling that there are leaks.
File Added: meta.patch
msg52231 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-03-16 20:27
Fixed all library and test code I could find that used __metaclass__.

The only two remaining tests (without -uall) failing are test_ast and test_compiler.
File Added: meta.patch
msg52232 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-03-16 23:12
Fix syntax error in pickletester.py
File Added: meta.patch
msg52233 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-03-18 15:49
Checked in as revision 54428. The PEP is accepted.

(And yes, I realize this has been quite the monologue. :-)
History
Date User Action Args
2008-01-06 22:29:46adminsetkeywords: - py3k
versions: + Python 3.0
2007-03-15 00:09:45gvanrossumcreate