Commit 9be0b2e3 authored by Benjamin Peterson's avatar Benjamin Peterson

detect non-ascii characters much earlier (plugs ref leak)

parent f13c6d8d
......@@ -764,6 +764,13 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
if (*f == 's')
++callcount;
}
else if (128 <= (unsigned char)*f) {
PyErr_Format(PyExc_ValueError,
"PyUnicode_FromFormatV() expects an ASCII-encoded format "
"string, got a non-ascii byte: 0x%02x",
(unsigned char)*f);
return NULL;
}
}
/* step 2: allocate memory for the results of
* PyObject_Str()/PyObject_Repr()/PyUnicode_DecodeUTF8() calls */
......@@ -1103,13 +1110,6 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
goto end;
}
}
else if (128 <= (unsigned char)*f) {
PyErr_Format(PyExc_ValueError,
"PyUnicode_FromFormatV() expects an ASCII-encoded format "
"string, got a non-ascii byte: 0x%02x",
(unsigned char)*f);
goto fail;
}
else
*s++ = *f;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment