summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-09-11 00:54:47 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-09-11 00:54:47 (GMT)
commit1205f2774e00d38d3229a3a2742c2fcbc767bdde (patch)
tree8f5756aa974326bf503dfaad7512aff103bde9bb /Objects
parentcd419abe42b42c626d91d5f839d53bdbde9852e0 (diff)
downloadcpython-1205f2774e00d38d3229a3a2742c2fcbc767bdde.zip
cpython-1205f2774e00d38d3229a3a2742c2fcbc767bdde.tar.gz
cpython-1205f2774e00d38d3229a3a2742c2fcbc767bdde.tar.bz2
Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
a non-ASCII byte in the format string. Document also the encoding.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 9cdf90d..c010b1b 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1102,7 +1102,15 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
appendstring(p);
goto end;
}
- } else
+ }
+ 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;
}