PyUnicode_GET_LENGTH(name));
if (!attr)
return 0;
- ADDOP_O(c, LOAD_ATTR, attr, names);
- Py_DECREF(attr);
+ ADDOP_N(c, LOAD_ATTR, attr, names);
pos = dot + 1;
}
}
if (level == NULL)
return 0;
- ADDOP_O(c, LOAD_CONST, level, consts);
- Py_DECREF(level);
+ ADDOP_N(c, LOAD_CONST, level, consts);
ADDOP_O(c, LOAD_CONST, Py_None, consts);
ADDOP_NAME(c, IMPORT_NAME, alias->name, names);
compiler_from_import(struct compiler *c, stmt_ty s)
{
Py_ssize_t i, n = asdl_seq_LEN(s->v.ImportFrom.names);
-
- PyObject *names = PyTuple_New(n);
- PyObject *level;
+ PyObject *level, *names;
static PyObject *empty_string;
if (!empty_string) {
return 0;
}
- if (!names)
- return 0;
-
level = PyLong_FromLong(s->v.ImportFrom.level);
if (!level) {
- Py_DECREF(names);
return 0;
}
+ ADDOP_N(c, LOAD_CONST, level, consts);
+
+ names = PyTuple_New(n);
+ if (!names)
+ return 0;
/* build up the names */
for (i = 0; i < n; i++) {
if (s->lineno > c->c_future->ff_lineno && s->v.ImportFrom.module &&
_PyUnicode_EqualToASCIIString(s->v.ImportFrom.module, "__future__")) {
- Py_DECREF(level);
Py_DECREF(names);
return compiler_error(c, "from __future__ imports must occur "
"at the beginning of the file");
}
+ ADDOP_N(c, LOAD_CONST, names, consts);
- ADDOP_O(c, LOAD_CONST, level, consts);
- Py_DECREF(level);
- ADDOP_O(c, LOAD_CONST, names, consts);
- Py_DECREF(names);
if (s->v.ImportFrom.module) {
ADDOP_NAME(c, IMPORT_NAME, s->v.ImportFrom.module, names);
}
store_name = alias->asname;
if (!compiler_nameop(c, store_name, Store)) {
- Py_DECREF(names);
return 0;
}
}
"param invalid for local variable");
return 0;
}
- ADDOP_O(c, op, mangled, varnames);
- Py_DECREF(mangled);
+ ADDOP_N(c, op, mangled, varnames);
return 1;
case OP_GLOBAL:
switch (ctx) {
if (s->v.AnnAssign.simple &&
(c->u->u_scope_type == COMPILER_SCOPE_MODULE ||
c->u->u_scope_type == COMPILER_SCOPE_CLASS)) {
+ VISIT(c, expr, s->v.AnnAssign.annotation);
mangled = _Py_Mangle(c->u->u_private, targ->v.Name.id);
if (!mangled) {
return 0;
}
- VISIT(c, expr, s->v.AnnAssign.annotation);
/* ADDOP_N decrefs its argument */
ADDOP_N(c, STORE_ANNOTATION, mangled, names);
}