summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-09-12 03:40:54 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-09-12 03:40:54 (GMT)
commit9be0b2e3122b8cb3078367e667bb6ab58cd81610 (patch)
tree93b151b91219e87aa8ee680c13c1ad7cc0e2cdd3 /Objects/unicodeobject.c
parentf13c6d8d34778c2aa2c35c490acb2bc580cc417a (diff)
downloadcpython-9be0b2e3122b8cb3078367e667bb6ab58cd81610.zip
cpython-9be0b2e3122b8cb3078367e667bb6ab58cd81610.tar.gz
cpython-9be0b2e3122b8cb3078367e667bb6ab58cd81610.tar.bz2
detect non-ascii characters much earlier (plugs ref leak)
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index c010b1b..3b0a66a 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;
}