summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-03-12 17:00:41 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-03-12 17:00:41 (GMT)
commit3f1af5c42e915775e9cc32224e090b05430a23de (patch)
tree0456ab762d139e628bc6e559291854a1a01a3feb /Objects
parent50981b8242af6a456cf17e39df6a12b0f98524df (diff)
downloadcpython-3f1af5c42e915775e9cc32224e090b05430a23de.zip
cpython-3f1af5c42e915775e9cc32224e090b05430a23de.tar.gz
cpython-3f1af5c42e915775e9cc32224e090b05430a23de.tar.bz2
Issue #6697: use %U format instead of _PyUnicode_AsString(), because
_PyUnicode_AsString() was not checked for error (NULL). The unicode string is no more truncated to 200 or 400 *bytes*.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/funcobject.c4
-rw-r--r--Objects/typeobject.c13
2 files changed, 11 insertions, 6 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 16851a9..35fc32d 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -295,9 +295,9 @@ func_set_code(PyFunctionObject *op, PyObject *value)
PyTuple_GET_SIZE(op->func_closure));
if (nclosure != nfree) {
PyErr_Format(PyExc_ValueError,
- "%s() requires a code object with %zd free vars,"
+ "%U() requires a code object with %zd free vars,"
" not %zd",
- _PyUnicode_AsString(op->func_name),
+ op->func_name,
nclosure, nfree);
return -1;
}
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index be4b6f8..7fd4cc8 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1295,10 +1295,15 @@ check_duplicates(PyObject *list)
for (j = i + 1; j < n; j++) {
if (PyList_GET_ITEM(list, j) == o) {
o = class_name(o);
- PyErr_Format(PyExc_TypeError,
- "duplicate base class %.400s",
- o ? _PyUnicode_AsString(o) : "?");
- Py_XDECREF(o);
+ if (o != NULL) {
+ PyErr_Format(PyExc_TypeError,
+ "duplicate base class %U",
+ o);
+ Py_DECREF(o);
+ } else {
+ PyErr_SetString(PyExc_TypeError,
+ "duplicate base class");
+ }
return -1;
}
}