Skip to content

Commit 4ddbdad

Browse files
committed
Simplify error formatting. Fix error message in
check_unoptimized().
1 parent 5d4ede1 commit 4ddbdad

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

Python/symtable.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,14 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags,
385385
if (flags & DEF_GLOBAL) {
386386
if (flags & DEF_PARAM) {
387387
PyErr_Format(PyExc_SyntaxError,
388-
"name '%s' is parameter and global",
389-
PyUnicode_AsString(name));
388+
"name '%U' is parameter and global",
389+
name);
390390
return 0;
391391
}
392392
if (flags & DEF_NONLOCAL) {
393393
PyErr_Format(PyExc_SyntaxError,
394-
"name '%s' is nonlocal and global",
395-
PyUnicode_AsString(name));
394+
"name '%U' is nonlocal and global",
395+
name);
396396
return 0;
397397
}
398398
SET_SCOPE(scopes, name, GLOBAL_EXPLICIT);
@@ -405,8 +405,8 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags,
405405
if (flags & DEF_NONLOCAL) {
406406
if (flags & DEF_PARAM) {
407407
PyErr_Format(PyExc_SyntaxError,
408-
"name '%s' is parameter and nonlocal",
409-
PyUnicode_AsString(name));
408+
"name '%U' is parameter and nonlocal",
409+
name);
410410
return 0;
411411
}
412412
if (!bound) {
@@ -416,8 +416,8 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags,
416416
}
417417
if (!PySet_Contains(bound, name)) {
418418
PyErr_Format(PyExc_SyntaxError,
419-
"no binding for nonlocal '%s' found",
420-
PyUnicode_AsString(name));
419+
"no binding for nonlocal '%U' found",
420+
name);
421421

422422
return 0;
423423
}
@@ -517,10 +517,10 @@ check_unoptimized(const PySTEntryObject* ste) {
517517
case OPT_TOPLEVEL: /* import * at top-level is fine */
518518
return 1;
519519
case OPT_IMPORT_STAR:
520-
PyOS_snprintf(buf, sizeof(buf),
521-
"import * is not allowed in function '%.100s' "
522-
"because it is %s",
523-
PyUnicode_AsString(ste->ste_name), trailer);
520+
PyOS_snprintf(buf, sizeof(buf),
521+
"import * is not allowed in function '%U' "
522+
"because it %s",
523+
ste->ste_name, trailer);
524524
break;
525525
}
526526

0 commit comments

Comments
 (0)