diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index c010b1b246c..3b0a66ae743 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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; }