summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2005-10-23 19:22:48 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2005-10-23 19:22:48 (GMT)
commit12ebfd79f8875ba19e4094eaa1e63f5f206b748b (patch)
tree9ca636d91b593c74d1bf1bdd85f143511aad6eb9 /Python
parent38eb50b227666e395015feb9b30280ef07f3299a (diff)
downloadcpython-12ebfd79f8875ba19e4094eaa1e63f5f206b748b.zip
cpython-12ebfd79f8875ba19e4094eaa1e63f5f206b748b.tar.gz
cpython-12ebfd79f8875ba19e4094eaa1e63f5f206b748b.tar.bz2
Use PyErr_NoMemory() instead of rolling our own.
Get rid of "int i" unused warnings from Python-ast.c which we are generating.
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c115
1 files changed, 54 insertions, 61 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index e82b61c..a425272 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -1,4 +1,4 @@
-/* File automatically generated by ../Parser/asdl_c.py */
+/* File automatically generated by ./Parser/asdl_c.py */
#include "Python.h"
#include "Python-ast.h"
@@ -9,7 +9,7 @@ Module(asdl_seq * body)
mod_ty p;
p = (mod_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Module_kind;
@@ -23,7 +23,7 @@ Interactive(asdl_seq * body)
mod_ty p;
p = (mod_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Interactive_kind;
@@ -42,7 +42,7 @@ Expression(expr_ty body)
}
p = (mod_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Expression_kind;
@@ -56,7 +56,7 @@ Suite(asdl_seq * body)
mod_ty p;
p = (mod_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Suite_kind;
@@ -81,7 +81,7 @@ FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *
}
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = FunctionDef_kind;
@@ -104,7 +104,7 @@ ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int lineno)
}
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = ClassDef_kind;
@@ -121,7 +121,7 @@ Return(expr_ty value, int lineno)
stmt_ty p;
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Return_kind;
@@ -136,7 +136,7 @@ Delete(asdl_seq * targets, int lineno)
stmt_ty p;
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Delete_kind;
@@ -156,7 +156,7 @@ Assign(asdl_seq * targets, expr_ty value, int lineno)
}
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Assign_kind;
@@ -187,7 +187,7 @@ AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno)
}
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = AugAssign_kind;
@@ -204,7 +204,7 @@ Print(expr_ty dest, asdl_seq * values, bool nl, int lineno)
stmt_ty p;
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Print_kind;
@@ -232,7 +232,7 @@ For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int
}
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = For_kind;
@@ -255,7 +255,7 @@ While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno)
}
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = While_kind;
@@ -277,7 +277,7 @@ If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno)
}
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = If_kind;
@@ -294,7 +294,7 @@ Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno)
stmt_ty p;
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Raise_kind;
@@ -311,7 +311,7 @@ TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int lineno)
stmt_ty p;
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = TryExcept_kind;
@@ -328,7 +328,7 @@ TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno)
stmt_ty p;
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = TryFinally_kind;
@@ -349,7 +349,7 @@ Assert(expr_ty test, expr_ty msg, int lineno)
}
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Assert_kind;
@@ -365,7 +365,7 @@ Import(asdl_seq * names, int lineno)
stmt_ty p;
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Import_kind;
@@ -385,7 +385,7 @@ ImportFrom(identifier module, asdl_seq * names, int lineno)
}
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = ImportFrom_kind;
@@ -406,7 +406,7 @@ Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno)
}
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Exec_kind;
@@ -423,7 +423,7 @@ Global(asdl_seq * names, int lineno)
stmt_ty p;
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Global_kind;
@@ -443,7 +443,7 @@ Expr(expr_ty value, int lineno)
}
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Expr_kind;
@@ -458,7 +458,7 @@ Pass(int lineno)
stmt_ty p;
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Pass_kind;
@@ -472,7 +472,7 @@ Break(int lineno)
stmt_ty p;
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Break_kind;
@@ -486,7 +486,7 @@ Continue(int lineno)
stmt_ty p;
p = (stmt_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Continue_kind;
@@ -505,7 +505,7 @@ BoolOp(boolop_ty op, asdl_seq * values, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = BoolOp_kind;
@@ -536,7 +536,7 @@ BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = BinOp_kind;
@@ -563,7 +563,7 @@ UnaryOp(unaryop_ty op, expr_ty operand, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = UnaryOp_kind;
@@ -589,7 +589,7 @@ Lambda(arguments_ty args, expr_ty body, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Lambda_kind;
@@ -605,7 +605,7 @@ Dict(asdl_seq * keys, asdl_seq * values, int lineno)
expr_ty p;
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Dict_kind;
@@ -626,7 +626,7 @@ ListComp(expr_ty elt, asdl_seq * generators, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = ListComp_kind;
@@ -647,7 +647,7 @@ GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = GeneratorExp_kind;
@@ -663,7 +663,7 @@ Yield(expr_ty value, int lineno)
expr_ty p;
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Yield_kind;
@@ -683,7 +683,7 @@ Compare(expr_ty left, asdl_seq * ops, asdl_seq * comparators, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Compare_kind;
@@ -706,7 +706,7 @@ Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs,
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Call_kind;
@@ -730,7 +730,7 @@ Repr(expr_ty value, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Repr_kind;
@@ -750,7 +750,7 @@ Num(object n, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Num_kind;
@@ -770,7 +770,7 @@ Str(string s, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Str_kind;
@@ -800,7 +800,7 @@ Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Attribute_kind;
@@ -832,7 +832,7 @@ Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Subscript_kind;
@@ -859,7 +859,7 @@ Name(identifier id, expr_context_ty ctx, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Name_kind;
@@ -880,7 +880,7 @@ List(asdl_seq * elts, expr_context_ty ctx, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = List_kind;
@@ -901,7 +901,7 @@ Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno)
}
p = (expr_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Tuple_kind;
@@ -917,7 +917,7 @@ Ellipsis()
slice_ty p;
p = (slice_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Ellipsis_kind;
@@ -930,7 +930,7 @@ Slice(expr_ty lower, expr_ty upper, expr_ty step)
slice_ty p;
p = (slice_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Slice_kind;
@@ -946,7 +946,7 @@ ExtSlice(asdl_seq * dims)
slice_ty p;
p = (slice_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = ExtSlice_kind;
@@ -965,7 +965,7 @@ Index(expr_ty value)
}
p = (slice_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->kind = Index_kind;
@@ -989,7 +989,7 @@ comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs)
}
p = (comprehension_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->target = target;
@@ -1004,7 +1004,7 @@ excepthandler(expr_ty type, expr_ty name, asdl_seq * body)
excepthandler_ty p;
p = (excepthandler_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->type = type;
@@ -1020,7 +1020,7 @@ arguments(asdl_seq * args, identifier vararg, identifier kwarg, asdl_seq *
arguments_ty p;
p = (arguments_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->args = args;
@@ -1046,7 +1046,7 @@ keyword(identifier arg, expr_ty value)
}
p = (keyword_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->arg = arg;
@@ -1065,7 +1065,7 @@ alias(identifier name, identifier asname)
}
p = (alias_ty)malloc(sizeof(*p));
if (!p) {
- PyErr_SetString(PyExc_MemoryError, "no memory");
+ PyErr_NoMemory();
return NULL;
}
p->name = name;
@@ -1992,7 +1992,6 @@ marshal_write_expr(PyObject **buf, int *off, expr_ty o)
int
marshal_write_expr_context(PyObject **buf, int *off, expr_context_ty o)
{
- int i;
switch (o) {
case Load:
marshal_write_int(buf, off, 1);
@@ -2067,7 +2066,6 @@ marshal_write_slice(PyObject **buf, int *off, slice_ty o)
int
marshal_write_boolop(PyObject **buf, int *off, boolop_ty o)
{
- int i;
switch (o) {
case And:
marshal_write_int(buf, off, 1);
@@ -2082,7 +2080,6 @@ marshal_write_boolop(PyObject **buf, int *off, boolop_ty o)
int
marshal_write_operator(PyObject **buf, int *off, operator_ty o)
{
- int i;
switch (o) {
case Add:
marshal_write_int(buf, off, 1);
@@ -2127,7 +2124,6 @@ marshal_write_operator(PyObject **buf, int *off, operator_ty o)
int
marshal_write_unaryop(PyObject **buf, int *off, unaryop_ty o)
{
- int i;
switch (o) {
case Invert:
marshal_write_int(buf, off, 1);
@@ -2148,7 +2144,6 @@ marshal_write_unaryop(PyObject **buf, int *off, unaryop_ty o)
int
marshal_write_cmpop(PyObject **buf, int *off, cmpop_ty o)
{
- int i;
switch (o) {
case Eq:
marshal_write_int(buf, off, 1);
@@ -2258,7 +2253,6 @@ marshal_write_arguments(PyObject **buf, int *off, arguments_ty o)
int
marshal_write_keyword(PyObject **buf, int *off, keyword_ty o)
{
- int i;
marshal_write_identifier(buf, off, o->arg);
marshal_write_expr(buf, off, o->value);
return 1;
@@ -2267,7 +2261,6 @@ marshal_write_keyword(PyObject **buf, int *off, keyword_ty o)
int
marshal_write_alias(PyObject **buf, int *off, alias_ty o)
{
- int i;
marshal_write_identifier(buf, off, o->name);
if (o->asname) {
marshal_write_int(buf, off, 1);