filename = PyString_AS_STRING(co->co_filename);
if (co->co_name && PyString_Check(co->co_name))
name = PyString_AS_STRING(co->co_name);
- sprintf(buf, "<code object %.100s at %p, file \"%.300s\", line %d>",
- name, co, filename, lineno);
+ PyOS_snprintf(buf, sizeof(buf),
+ "<code object %.100s at %p, file \"%.300s\", line %d>",
+ name, co, filename, lineno);
return PyString_FromString(buf);
}
break;
case NAME_CLOSURE: {
char buf[500];
- sprintf(buf, DEL_CLOSURE_ERROR, name);
+ PyOS_snprintf(buf, sizeof(buf),
+ DEL_CLOSURE_ERROR, name);
com_error(c, PyExc_SyntaxError, buf);
i = 255;
break;
com_list_comprehension(struct compiling *c, node *n)
{
/* listmaker: test list_for */
- char tmpname[12];
- sprintf(tmpname, "_[%d]", ++c->c_tmpname);
+ char tmpname[30];
+ PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]", ++c->c_tmpname);
com_addoparg(c, BUILD_LIST, 0);
com_addbyte(c, DUP_TOP); /* leave the result on the stack */
com_push(c, 2);
{
int nch, i, narg;
int complex = 0;
- char nbuf[10];
+ char nbuf[30];
REQ(n, varargslist);
/* varargslist:
(fpdef ['=' test] ',')* (fpdef ['=' test] | '*' .....) */
REQ(ch, fpdef); /* fpdef: NAME | '(' fplist ')' */
fp = CHILD(ch, 0);
if (TYPE(fp) != NAME) {
- sprintf(nbuf, ".%d", i);
+ PyOS_snprintf(nbuf, sizeof(nbuf), ".%d", i);
complex = 1;
}
narg++;
if (ste->ste_child_free) {
if (ste->ste_optimized == OPT_IMPORT_STAR)
- sprintf(buf, ILLEGAL_IMPORT_STAR,
- PyString_AS_STRING(ste->ste_name),
- ILLEGAL_CONTAINS);
+ PyOS_snprintf(buf, sizeof(buf),
+ ILLEGAL_IMPORT_STAR,
+ PyString_AS_STRING(ste->ste_name),
+ ILLEGAL_CONTAINS);
else if (ste->ste_optimized == (OPT_BARE_EXEC | OPT_EXEC))
- sprintf(buf, ILLEGAL_BARE_EXEC,
- PyString_AS_STRING(ste->ste_name),
- ILLEGAL_CONTAINS);
+ PyOS_snprintf(buf, sizeof(buf),
+ ILLEGAL_BARE_EXEC,
+ PyString_AS_STRING(ste->ste_name),
+ ILLEGAL_CONTAINS);
else {
- sprintf(buf, ILLEGAL_EXEC_AND_IMPORT_STAR,
- PyString_AS_STRING(ste->ste_name),
- ILLEGAL_CONTAINS);
+ PyOS_snprintf(buf, sizeof(buf),
+ ILLEGAL_EXEC_AND_IMPORT_STAR,
+ PyString_AS_STRING(ste->ste_name),
+ ILLEGAL_CONTAINS);
}
} else {
if (ste->ste_optimized == OPT_IMPORT_STAR)
- sprintf(buf, ILLEGAL_IMPORT_STAR,
- PyString_AS_STRING(ste->ste_name),
- ILLEGAL_IS);
+ PyOS_snprintf(buf, sizeof(buf),
+ ILLEGAL_IMPORT_STAR,
+ PyString_AS_STRING(ste->ste_name),
+ ILLEGAL_IS);
else if (ste->ste_optimized == (OPT_BARE_EXEC | OPT_EXEC))
- sprintf(buf, ILLEGAL_BARE_EXEC,
- PyString_AS_STRING(ste->ste_name),
- ILLEGAL_IS);
+ PyOS_snprintf(buf, sizeof(buf),
+ ILLEGAL_BARE_EXEC,
+ PyString_AS_STRING(ste->ste_name),
+ ILLEGAL_IS);
else {
- sprintf(buf, ILLEGAL_EXEC_AND_IMPORT_STAR,
- PyString_AS_STRING(ste->ste_name),
- ILLEGAL_IS);
+ PyOS_snprintf(buf, sizeof(buf),
+ ILLEGAL_EXEC_AND_IMPORT_STAR,
+ PyString_AS_STRING(ste->ste_name),
+ ILLEGAL_IS);
}
}
if (TYPE(CHILD(c, 0)) == NAME)
symtable_add_def(st, STR(CHILD(c, 0)), DEF_PARAM);
else {
- char nbuf[10];
- sprintf(nbuf, ".%d", i);
+ char nbuf[30];
+ PyOS_snprintf(nbuf, sizeof(nbuf), ".%d", i);
symtable_add_def(st, nbuf, DEF_PARAM);
complex = i;
}
}
else {
if (flags & DEF_LOCAL)
- sprintf(buf, GLOBAL_AFTER_ASSIGN,
- name);
+ PyOS_snprintf(buf, sizeof(buf),
+ GLOBAL_AFTER_ASSIGN,
+ name);
else
- sprintf(buf, GLOBAL_AFTER_USE, name);
+ PyOS_snprintf(buf, sizeof(buf),
+ GLOBAL_AFTER_USE, name);
symtable_warn(st, buf);
}
}
static void
symtable_list_comprehension(struct symtable *st, node *n)
{
- char tmpname[12];
+ char tmpname[30];
- sprintf(tmpname, "_[%d]", st->st_tmpname);
+ PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]", st->st_tmpname);
symtable_add_def(st, tmpname, DEF_LOCAL);
symtable_assign(st, CHILD(n, 1), 0);
symtable_node(st, CHILD(n, 3));