str = PyString_AsString(arg);
if (str == NULL) {
err_repr = PyObject_Repr(arg);
+ if (err_repr == NULL)
+ return NULL;
PyErr_Format(
PyExc_ValueError,
- "Couldn't parse datetime string '%s' - value is not a string.",
+ "Couldn't parse datetime string '%.200s' "
+ "- value is not a string.",
PyString_AsString(err_repr));
Py_DECREF(err_repr);
return NULL;
if (sscanf(str, "%4u-%2u-%2u %2u:%2u:%2u.%6u", &year, &month, &day,
&hour, &minute, &second, µsecond) < 6) {
err_repr = PyObject_Repr(arg);
+ if (err_repr == NULL)
+ return NULL;
PyErr_Format(
PyExc_ValueError,
- "Couldn't parse datetime string: %s",
+ "Couldn't parse datetime string: %.200s",
PyString_AsString(err_repr));
Py_DECREF(err_repr);
return NULL;
str = PyString_AsString(arg);
if (str == NULL) {
err_repr = PyObject_Repr(arg);
+ if (err_repr == NULL)
+ return NULL;
PyErr_Format(
PyExc_ValueError,
- "Couldn't parse time string '%s' - value is not a string.",
+ "Couldn't parse time string '%.200s' - value is not a string.",
PyString_AsString(err_repr));
Py_DECREF(err_repr);
return NULL;
if (sscanf(str, "%2u:%2u:%2u.%6u", &hour, &minute, &second,
µsecond) < 3) {
err_repr = PyObject_Repr(arg);
+ if (err_repr == NULL)
+ return NULL;
PyErr_Format(
PyExc_ValueError,
- "Couldn't parse time string: %s",
+ "Couldn't parse time string: %.200s",
PyString_AsString(err_repr));
Py_DECREF(err_repr);
return NULL;
str = PyString_AsString(arg);
if (str == NULL) {
err_repr = PyObject_Repr(arg);
+ if (err_repr == NULL)
+ return NULL;
PyErr_Format(
PyExc_ValueError,
- "Couldn't parse date string '%s' - value is not a string.",
+ "Couldn't parse date string '%.200s' - value is not a string.",
PyString_AsString(err_repr));
Py_DECREF(err_repr);
return NULL;
if (sscanf(str, "%4u-%2u-%2u", &year, &month, &day) != 3) {
err_repr = PyObject_Repr(arg);
+ if (err_repr == NULL)
+ return NULL;
PyErr_Format(
PyExc_ValueError,
- "Couldn't parse date string: %s",
+ "Couldn't parse date string: %.200s",
PyString_AsString(err_repr));
Py_DECREF(err_repr);
return NULL;