Mercurial > cpython-lru_cache-weakref
diff Python/compile.c @ 34696:a0d3f773543d legacy-trunk
Allow classes to be defined with empty parentheses. This means that
``class C(): pass`` is no longer a syntax error.
| author | Brett Cannon <bcannon@gmail.com> |
|---|---|
| date | Sat, 05 Mar 2005 06:47:57 +0000 |
| parents | a9f161e36bf9 |
| children | 70681267a74a |
line wrap: on
line diff
--- a/Python/compile.c Sat Mar 05 06:40:52 2005 +0000 +++ b/Python/compile.c Sat Mar 05 06:47:57 2005 +0000 @@ -4624,7 +4624,7 @@ char *name; REQ(n, classdef); - /* classdef: class NAME ['(' testlist ')'] ':' suite */ + /* classdef: class NAME ['(' [testlist] ')'] ':' suite */ if ((v = PyString_InternFromString(STR(CHILD(n, 1)))) == NULL) { c->c_errors++; return; @@ -4635,7 +4635,8 @@ com_push(c, 1); Py_DECREF(v); /* Push the tuple of base classes on the stack */ - if (TYPE(CHILD(n, 2)) != LPAR) { + if (TYPE(CHILD(n, 2)) != LPAR || + TYPE(CHILD(n, 3)) == RPAR) { com_addoparg(c, BUILD_TUPLE, 0); com_push(c, 1); }
