summaryrefslogtreecommitdiffstats
path: root/Modules/pyexpat.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-03-21 12:26:24 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-03-21 12:26:24 (GMT)
commit499dfcf29da7b7d1ca11f697cece773936c2ba42 (patch)
tree5b295eac3254ac6d6f0253d037081d7456ff9d7c /Modules/pyexpat.c
parentbfc7bf06a63b5bf4cac0dae7c0d370fbc81563f9 (diff)
downloadcpython-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/pyexpat.c')
-rw-r--r--Modules/pyexpat.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index ee59baf..9b78d7e 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -100,16 +100,17 @@ static PyObject *
set_error(xmlparseobject *self, enum XML_Error code)
{
PyObject *err;
- char buffer[256];
+ PyObject *buffer;
XML_Parser parser = self->itself;
int lineno = XML_GetErrorLineNumber(parser);
int column = XML_GetErrorColumnNumber(parser);
- /* There is no risk of overflowing this buffer, since
- even for 64-bit integers, there is sufficient space. */
- sprintf(buffer, "%.200s: line %i, column %i",
- XML_ErrorString(code), lineno, column);
- err = PyObject_CallFunction(ErrorObject, "s", buffer);
+ buffer = PyUnicode_FromFormat("%s: line %i, column %i",
+ XML_ErrorString(code), lineno, column);
+ if (buffer == NULL)
+ return NULL;
+ err = PyObject_CallFunction(ErrorObject, "O", buffer);
+ Py_DECREF(buffer);
if ( err != NULL
&& set_error_attr(err, "code", code)
&& set_error_attr(err, "offset", column)