Merged revisions 53912-53951 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r53919 | thomas.wouters | 2007-02-25 23:12:31 +0100 (Sun, 25 Feb 2007) | 8 lines


  Backported r51621 from p3yk:

  Don't use a fixed temporary name (gdbm).
  Don't use our own temp name creation (dbm).
  Should be backported to 2.5.
........
  r53935 | georg.brandl | 2007-02-26 14:51:29 +0100 (Mon, 26 Feb 2007) | 2 lines

  Backport from Py3k branch: fix refleak in PyString_Format.
........
  r53943 | jeremy.hylton | 2007-02-26 17:14:51 +0100 (Mon, 26 Feb 2007) | 2 lines

  Reformat long lines.
........
  r53947 | neal.norwitz | 2007-02-26 18:01:08 +0100 (Mon, 26 Feb 2007) | 1 line

  Add Steven Bethard to help out with patches.
........
  r53949 | georg.brandl | 2007-02-26 18:09:03 +0100 (Mon, 26 Feb 2007) | 3 lines

  Fix typo.
........
  r53951 | neal.norwitz | 2007-02-26 19:10:47 +0100 (Mon, 26 Feb 2007) | 5 lines

  Fix a couple of problems in generating the AST code:
   * use %r instead of backticks since backticks are going away in Py3k
   * PyArena_Malloc() already sets PyErr_NoMemory so we don't need to do it again
   * the signature for ast2obj_int incorrectly used a bool, rather than a long
........
This commit is contained in:
Thomas Wouters 2007-02-26 18:20:15 +00:00
parent a88a0331b7
commit a44f3a3e0b
4 changed files with 68 additions and 177 deletions

View File

@ -17,6 +17,9 @@ the format to accommodate documentation needs as they arise.
Permissions History Permissions History
------------------- -------------------
- Steven Bethard (SF name "bediviere") added to the SourceForge Python
project 26 Feb 2007, by NCN, as a tracker tech.
- Josiah Carlson (SF name "josiahcarlson") added to the SourceForge Python - Josiah Carlson (SF name "josiahcarlson") added to the SourceForge Python
project 06 Jan 2007, by NCN, as a tracker tech. He will maintain asyncore. project 06 Jan 2007, by NCN, as a tracker tech. He will maintain asyncore.

View File

@ -299,10 +299,8 @@ class FunctionVisitor(PrototypeVisitor):
emit('}', 1) emit('}', 1)
emit("p = (%s)PyArena_Malloc(arena, sizeof(*p));" % ctype, 1); emit("p = (%s)PyArena_Malloc(arena, sizeof(*p));" % ctype, 1);
emit("if (!p) {", 1) emit("if (!p)", 1)
emit("PyErr_NoMemory();", 2)
emit("return NULL;", 2) emit("return NULL;", 2)
emit("}", 1)
if union: if union:
self.emit_body_union(name, args, attrs) self.emit_body_union(name, args, attrs)
else: else:
@ -474,7 +472,7 @@ static PyObject* ast2obj_bool(bool b)
return PyBool_FromLong(b); return PyBool_FromLong(b);
} }
static PyObject* ast2obj_int(bool b) static PyObject* ast2obj_int(long b)
{ {
return PyInt_FromLong(b); return PyInt_FromLong(b);
} }

View File

@ -2,7 +2,7 @@
/* /*
__version__ 53872. __version__ 53873.
This module must be committed separately after each AST grammar change; This module must be committed separately after each AST grammar change;
The __version__ number is set to the revision number of the commit The __version__ number is set to the revision number of the commit
@ -448,7 +448,7 @@ static PyObject* ast2obj_bool(bool b)
return PyBool_FromLong(b); return PyBool_FromLong(b);
} }
static PyObject* ast2obj_int(bool b) static PyObject* ast2obj_int(long b)
{ {
return PyInt_FromLong(b); return PyInt_FromLong(b);
} }
@ -754,10 +754,8 @@ Module(asdl_seq * body, PyArena *arena)
{ {
mod_ty p; mod_ty p;
p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Module_kind; p->kind = Module_kind;
p->v.Module.body = body; p->v.Module.body = body;
return p; return p;
@ -768,10 +766,8 @@ Interactive(asdl_seq * body, PyArena *arena)
{ {
mod_ty p; mod_ty p;
p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Interactive_kind; p->kind = Interactive_kind;
p->v.Interactive.body = body; p->v.Interactive.body = body;
return p; return p;
@ -787,10 +783,8 @@ Expression(expr_ty body, PyArena *arena)
return NULL; return NULL;
} }
p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Expression_kind; p->kind = Expression_kind;
p->v.Expression.body = body; p->v.Expression.body = body;
return p; return p;
@ -801,10 +795,8 @@ Suite(asdl_seq * body, PyArena *arena)
{ {
mod_ty p; mod_ty p;
p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Suite_kind; p->kind = Suite_kind;
p->v.Suite.body = body; p->v.Suite.body = body;
return p; return p;
@ -827,10 +819,8 @@ FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *
return NULL; return NULL;
} }
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = FunctionDef_kind; p->kind = FunctionDef_kind;
p->v.FunctionDef.name = name; p->v.FunctionDef.name = name;
p->v.FunctionDef.args = args; p->v.FunctionDef.args = args;
@ -853,10 +843,8 @@ ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int lineno, int
return NULL; return NULL;
} }
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = ClassDef_kind; p->kind = ClassDef_kind;
p->v.ClassDef.name = name; p->v.ClassDef.name = name;
p->v.ClassDef.bases = bases; p->v.ClassDef.bases = bases;
@ -871,10 +859,8 @@ Return(expr_ty value, int lineno, int col_offset, PyArena *arena)
{ {
stmt_ty p; stmt_ty p;
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Return_kind; p->kind = Return_kind;
p->v.Return.value = value; p->v.Return.value = value;
p->lineno = lineno; p->lineno = lineno;
@ -887,10 +873,8 @@ Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena)
{ {
stmt_ty p; stmt_ty p;
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Delete_kind; p->kind = Delete_kind;
p->v.Delete.targets = targets; p->v.Delete.targets = targets;
p->lineno = lineno; p->lineno = lineno;
@ -909,10 +893,8 @@ Assign(asdl_seq * targets, expr_ty value, int lineno, int col_offset, PyArena
return NULL; return NULL;
} }
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Assign_kind; p->kind = Assign_kind;
p->v.Assign.targets = targets; p->v.Assign.targets = targets;
p->v.Assign.value = value; p->v.Assign.value = value;
@ -942,10 +924,8 @@ AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
return NULL; return NULL;
} }
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = AugAssign_kind; p->kind = AugAssign_kind;
p->v.AugAssign.target = target; p->v.AugAssign.target = target;
p->v.AugAssign.op = op; p->v.AugAssign.op = op;
@ -971,10 +951,8 @@ For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int
return NULL; return NULL;
} }
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = For_kind; p->kind = For_kind;
p->v.For.target = target; p->v.For.target = target;
p->v.For.iter = iter; p->v.For.iter = iter;
@ -996,10 +974,8 @@ While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
return NULL; return NULL;
} }
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = While_kind; p->kind = While_kind;
p->v.While.test = test; p->v.While.test = test;
p->v.While.body = body; p->v.While.body = body;
@ -1020,10 +996,8 @@ If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
return NULL; return NULL;
} }
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = If_kind; p->kind = If_kind;
p->v.If.test = test; p->v.If.test = test;
p->v.If.body = body; p->v.If.body = body;
@ -1044,10 +1018,8 @@ With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, int lineno,
return NULL; return NULL;
} }
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = With_kind; p->kind = With_kind;
p->v.With.context_expr = context_expr; p->v.With.context_expr = context_expr;
p->v.With.optional_vars = optional_vars; p->v.With.optional_vars = optional_vars;
@ -1063,10 +1035,8 @@ Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int col_offset,
{ {
stmt_ty p; stmt_ty p;
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Raise_kind; p->kind = Raise_kind;
p->v.Raise.type = type; p->v.Raise.type = type;
p->v.Raise.inst = inst; p->v.Raise.inst = inst;
@ -1082,10 +1052,8 @@ TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int lineno,
{ {
stmt_ty p; stmt_ty p;
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = TryExcept_kind; p->kind = TryExcept_kind;
p->v.TryExcept.body = body; p->v.TryExcept.body = body;
p->v.TryExcept.handlers = handlers; p->v.TryExcept.handlers = handlers;
@ -1101,10 +1069,8 @@ TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int col_offset,
{ {
stmt_ty p; stmt_ty p;
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = TryFinally_kind; p->kind = TryFinally_kind;
p->v.TryFinally.body = body; p->v.TryFinally.body = body;
p->v.TryFinally.finalbody = finalbody; p->v.TryFinally.finalbody = finalbody;
@ -1123,10 +1089,8 @@ Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena *arena)
return NULL; return NULL;
} }
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Assert_kind; p->kind = Assert_kind;
p->v.Assert.test = test; p->v.Assert.test = test;
p->v.Assert.msg = msg; p->v.Assert.msg = msg;
@ -1140,10 +1104,8 @@ Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
{ {
stmt_ty p; stmt_ty p;
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Import_kind; p->kind = Import_kind;
p->v.Import.names = names; p->v.Import.names = names;
p->lineno = lineno; p->lineno = lineno;
@ -1162,10 +1124,8 @@ ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int
return NULL; return NULL;
} }
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = ImportFrom_kind; p->kind = ImportFrom_kind;
p->v.ImportFrom.module = module; p->v.ImportFrom.module = module;
p->v.ImportFrom.names = names; p->v.ImportFrom.names = names;
@ -1180,10 +1140,8 @@ Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
{ {
stmt_ty p; stmt_ty p;
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Global_kind; p->kind = Global_kind;
p->v.Global.names = names; p->v.Global.names = names;
p->lineno = lineno; p->lineno = lineno;
@ -1201,10 +1159,8 @@ Expr(expr_ty value, int lineno, int col_offset, PyArena *arena)
return NULL; return NULL;
} }
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Expr_kind; p->kind = Expr_kind;
p->v.Expr.value = value; p->v.Expr.value = value;
p->lineno = lineno; p->lineno = lineno;
@ -1217,10 +1173,8 @@ Pass(int lineno, int col_offset, PyArena *arena)
{ {
stmt_ty p; stmt_ty p;
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Pass_kind; p->kind = Pass_kind;
p->lineno = lineno; p->lineno = lineno;
p->col_offset = col_offset; p->col_offset = col_offset;
@ -1232,10 +1186,8 @@ Break(int lineno, int col_offset, PyArena *arena)
{ {
stmt_ty p; stmt_ty p;
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Break_kind; p->kind = Break_kind;
p->lineno = lineno; p->lineno = lineno;
p->col_offset = col_offset; p->col_offset = col_offset;
@ -1247,10 +1199,8 @@ Continue(int lineno, int col_offset, PyArena *arena)
{ {
stmt_ty p; stmt_ty p;
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Continue_kind; p->kind = Continue_kind;
p->lineno = lineno; p->lineno = lineno;
p->col_offset = col_offset; p->col_offset = col_offset;
@ -1268,10 +1218,8 @@ BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, PyArena
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = BoolOp_kind; p->kind = BoolOp_kind;
p->v.BoolOp.op = op; p->v.BoolOp.op = op;
p->v.BoolOp.values = values; p->v.BoolOp.values = values;
@ -1301,10 +1249,8 @@ BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset,
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = BinOp_kind; p->kind = BinOp_kind;
p->v.BinOp.left = left; p->v.BinOp.left = left;
p->v.BinOp.op = op; p->v.BinOp.op = op;
@ -1330,10 +1276,8 @@ UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, PyArena
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = UnaryOp_kind; p->kind = UnaryOp_kind;
p->v.UnaryOp.op = op; p->v.UnaryOp.op = op;
p->v.UnaryOp.operand = operand; p->v.UnaryOp.operand = operand;
@ -1358,10 +1302,8 @@ Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, PyArena
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Lambda_kind; p->kind = Lambda_kind;
p->v.Lambda.args = args; p->v.Lambda.args = args;
p->v.Lambda.body = body; p->v.Lambda.body = body;
@ -1391,10 +1333,8 @@ IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset,
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = IfExp_kind; p->kind = IfExp_kind;
p->v.IfExp.test = test; p->v.IfExp.test = test;
p->v.IfExp.body = body; p->v.IfExp.body = body;
@ -1410,10 +1350,8 @@ Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena
{ {
expr_ty p; expr_ty p;
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Dict_kind; p->kind = Dict_kind;
p->v.Dict.keys = keys; p->v.Dict.keys = keys;
p->v.Dict.values = values; p->v.Dict.values = values;
@ -1427,10 +1365,8 @@ Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena)
{ {
expr_ty p; expr_ty p;
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Set_kind; p->kind = Set_kind;
p->v.Set.elts = elts; p->v.Set.elts = elts;
p->lineno = lineno; p->lineno = lineno;
@ -1449,10 +1385,8 @@ ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = ListComp_kind; p->kind = ListComp_kind;
p->v.ListComp.elt = elt; p->v.ListComp.elt = elt;
p->v.ListComp.generators = generators; p->v.ListComp.generators = generators;
@ -1472,10 +1406,8 @@ GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = GeneratorExp_kind; p->kind = GeneratorExp_kind;
p->v.GeneratorExp.elt = elt; p->v.GeneratorExp.elt = elt;
p->v.GeneratorExp.generators = generators; p->v.GeneratorExp.generators = generators;
@ -1489,10 +1421,8 @@ Yield(expr_ty value, int lineno, int col_offset, PyArena *arena)
{ {
expr_ty p; expr_ty p;
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Yield_kind; p->kind = Yield_kind;
p->v.Yield.value = value; p->v.Yield.value = value;
p->lineno = lineno; p->lineno = lineno;
@ -1511,10 +1441,8 @@ Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno,
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Compare_kind; p->kind = Compare_kind;
p->v.Compare.left = left; p->v.Compare.left = left;
p->v.Compare.ops = ops; p->v.Compare.ops = ops;
@ -1535,10 +1463,8 @@ Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs,
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Call_kind; p->kind = Call_kind;
p->v.Call.func = func; p->v.Call.func = func;
p->v.Call.args = args; p->v.Call.args = args;
@ -1560,10 +1486,8 @@ Num(object n, int lineno, int col_offset, PyArena *arena)
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Num_kind; p->kind = Num_kind;
p->v.Num.n = n; p->v.Num.n = n;
p->lineno = lineno; p->lineno = lineno;
@ -1581,10 +1505,8 @@ Str(string s, int lineno, int col_offset, PyArena *arena)
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Str_kind; p->kind = Str_kind;
p->v.Str.s = s; p->v.Str.s = s;
p->lineno = lineno; p->lineno = lineno;
@ -1602,10 +1524,8 @@ Bytes(string s, int lineno, int col_offset, PyArena *arena)
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Bytes_kind; p->kind = Bytes_kind;
p->v.Bytes.s = s; p->v.Bytes.s = s;
p->lineno = lineno; p->lineno = lineno;
@ -1618,10 +1538,8 @@ Ellipsis(int lineno, int col_offset, PyArena *arena)
{ {
expr_ty p; expr_ty p;
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Ellipsis_kind; p->kind = Ellipsis_kind;
p->lineno = lineno; p->lineno = lineno;
p->col_offset = col_offset; p->col_offset = col_offset;
@ -1649,10 +1567,8 @@ Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Attribute_kind; p->kind = Attribute_kind;
p->v.Attribute.value = value; p->v.Attribute.value = value;
p->v.Attribute.attr = attr; p->v.Attribute.attr = attr;
@ -1683,10 +1599,8 @@ Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno, int
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Subscript_kind; p->kind = Subscript_kind;
p->v.Subscript.value = value; p->v.Subscript.value = value;
p->v.Subscript.slice = slice; p->v.Subscript.slice = slice;
@ -1712,10 +1626,8 @@ Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Name_kind; p->kind = Name_kind;
p->v.Name.id = id; p->v.Name.id = id;
p->v.Name.ctx = ctx; p->v.Name.ctx = ctx;
@ -1735,10 +1647,8 @@ List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = List_kind; p->kind = List_kind;
p->v.List.elts = elts; p->v.List.elts = elts;
p->v.List.ctx = ctx; p->v.List.ctx = ctx;
@ -1758,10 +1668,8 @@ Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena
return NULL; return NULL;
} }
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Tuple_kind; p->kind = Tuple_kind;
p->v.Tuple.elts = elts; p->v.Tuple.elts = elts;
p->v.Tuple.ctx = ctx; p->v.Tuple.ctx = ctx;
@ -1775,10 +1683,8 @@ Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena)
{ {
slice_ty p; slice_ty p;
p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Slice_kind; p->kind = Slice_kind;
p->v.Slice.lower = lower; p->v.Slice.lower = lower;
p->v.Slice.upper = upper; p->v.Slice.upper = upper;
@ -1791,10 +1697,8 @@ ExtSlice(asdl_seq * dims, PyArena *arena)
{ {
slice_ty p; slice_ty p;
p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = ExtSlice_kind; p->kind = ExtSlice_kind;
p->v.ExtSlice.dims = dims; p->v.ExtSlice.dims = dims;
return p; return p;
@ -1810,10 +1714,8 @@ Index(expr_ty value, PyArena *arena)
return NULL; return NULL;
} }
p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = Index_kind; p->kind = Index_kind;
p->v.Index.value = value; p->v.Index.value = value;
return p; return p;
@ -1834,10 +1736,8 @@ comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena)
return NULL; return NULL;
} }
p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->target = target; p->target = target;
p->iter = iter; p->iter = iter;
p->ifs = ifs; p->ifs = ifs;
@ -1850,10 +1750,8 @@ excepthandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int
{ {
excepthandler_ty p; excepthandler_ty p;
p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->type = type; p->type = type;
p->name = name; p->name = name;
p->body = body; p->body = body;
@ -1869,10 +1767,8 @@ arguments(asdl_seq * args, identifier vararg, expr_ty varargannotation,
{ {
arguments_ty p; arguments_ty p;
p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->args = args; p->args = args;
p->vararg = vararg; p->vararg = vararg;
p->varargannotation = varargannotation; p->varargannotation = varargannotation;
@ -1894,10 +1790,8 @@ SimpleArg(identifier arg, expr_ty annotation, PyArena *arena)
return NULL; return NULL;
} }
p = (arg_ty)PyArena_Malloc(arena, sizeof(*p)); p = (arg_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = SimpleArg_kind; p->kind = SimpleArg_kind;
p->v.SimpleArg.arg = arg; p->v.SimpleArg.arg = arg;
p->v.SimpleArg.annotation = annotation; p->v.SimpleArg.annotation = annotation;
@ -1909,10 +1803,8 @@ NestedArgs(asdl_seq * args, PyArena *arena)
{ {
arg_ty p; arg_ty p;
p = (arg_ty)PyArena_Malloc(arena, sizeof(*p)); p = (arg_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->kind = NestedArgs_kind; p->kind = NestedArgs_kind;
p->v.NestedArgs.args = args; p->v.NestedArgs.args = args;
return p; return p;
@ -1933,10 +1825,8 @@ keyword(identifier arg, expr_ty value, PyArena *arena)
return NULL; return NULL;
} }
p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->arg = arg; p->arg = arg;
p->value = value; p->value = value;
return p; return p;
@ -1952,10 +1842,8 @@ alias(identifier name, identifier asname, PyArena *arena)
return NULL; return NULL;
} }
p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); p = (alias_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) { if (!p)
PyErr_NoMemory();
return NULL; return NULL;
}
p->name = name; p->name = name;
p->asname = asname; p->asname = asname;
return p; return p;
@ -3125,7 +3013,7 @@ init_ast(void)
if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return;
if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
return; return;
if (PyModule_AddStringConstant(m, "__version__", "53872") < 0) if (PyModule_AddStringConstant(m, "__version__", "53873") < 0)
return; return;
if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return;
if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)

View File

@ -4077,7 +4077,8 @@ build_class(PyObject *methods, PyObject *bases, PyObject *name)
metaclass = (PyObject *) &PyType_Type; metaclass = (PyObject *) &PyType_Type;
Py_INCREF(metaclass); Py_INCREF(metaclass);
} }
result = PyObject_CallFunctionObjArgs(metaclass, name, bases, methods, NULL); result = PyObject_CallFunctionObjArgs(metaclass, name, bases, methods,
NULL);
Py_DECREF(metaclass); Py_DECREF(metaclass);
if (result == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) { if (result == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {
/* A type error here likely means that the user passed /* A type error here likely means that the user passed
@ -4091,7 +4092,8 @@ build_class(PyObject *methods, PyObject *bases, PyObject *name)
if (PyString_Check(pvalue)) { if (PyString_Check(pvalue)) {
PyObject *newmsg; PyObject *newmsg;
newmsg = PyString_FromFormat( newmsg = PyString_FromFormat(
"Error when calling the metaclass bases\n %s", "Error when calling the metaclass bases\n"
" %s",
PyString_AS_STRING(pvalue)); PyString_AS_STRING(pvalue));
if (newmsg != NULL) { if (newmsg != NULL) {
Py_DECREF(pvalue); Py_DECREF(pvalue);