diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-21 12:26:24 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-21 12:26:24 (GMT) |
commit | 499dfcf29da7b7d1ca11f697cece773936c2ba42 (patch) | |
tree | 5b295eac3254ac6d6f0253d037081d7456ff9d7c /Modules/_elementtree.c | |
parent | bfc7bf06a63b5bf4cac0dae7c0d370fbc81563f9 (diff) | |
download | cpython-499dfcf29da7b7d1ca11f697cece773936c2ba42.zip cpython-499dfcf29da7b7d1ca11f697cece773936c2ba42.tar.gz cpython-499dfcf29da7b7d1ca11f697cece773936c2ba42.tar.bz2 |
Issue #10833: Use PyUnicode_FromFormat() and PyErr_Format() instead of
PyOS_snprintf().
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r-- | Modules/_elementtree.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 5983a3b..6373c48 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2138,13 +2138,15 @@ makeuniversal(XMLParserObject* self, const char* string) static void expat_set_error(const char* message, int line, int column) { - PyObject *error; - PyObject *position; - char buffer[256]; + PyObject *errmsg, *error, *position; - sprintf(buffer, "%.100s: line %d, column %d", message, line, column); + errmsg = PyUnicode_FromFormat("%s: line %d, column %d", + message, line, column); + if (errmsg == NULL) + return; - error = PyObject_CallFunction(elementtree_parseerror_obj, "s", buffer); + error = PyObject_CallFunction(elementtree_parseerror_obj, "O", errmsg); + Py_DECREF(errmsg); if (!error) return; |