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

This commit is contained in:
Benjamin Peterson 2010-09-12 03:40:54 +00:00
parent f13c6d8d34
commit 9be0b2e312
1 changed files with 7 additions and 7 deletions

View File

@ -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;
}