summaryrefslogtreecommitdiff
path: root/Python/compile.c
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2005-03-05 06:47:57 +0000
committerBrett Cannon <bcannon@gmail.com>2005-03-05 06:47:57 +0000
commit409d8f2ebdf597837c593a40659949e5b15f457d (patch)
tree65efd1daca556adb53a28d3957ba57dc801e0dda /Python/compile.c
parent653a5adcca68d445b21dd2a640627f0f0185204a (diff)
downloadcpython-git-409d8f2ebdf597837c593a40659949e5b15f457d.tar.gz
Allow classes to be defined with empty parentheses. This means that
``class C(): pass`` is no longer a syntax error.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 16bf291708..5781b21ce4 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -4624,7 +4624,7 @@ com_classdef(struct compiling *c, node *n)
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_classdef(struct compiling *c, node *n)
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);
}