[Python-checkins] cpython: unicode_fromascii() doesn't check string content twice in debug mode
victor.stinner
python-checkins at python.org
Mon Dec 12 01:25:55 CET 2011
http://hg.python.org/cpython/rev/d728637f5d78
changeset: 73936:d728637f5d78
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Sun Dec 11 21:54:30 2011 +0100
summary:
unicode_fromascii() doesn't check string content twice in debug mode
_PyUnicode_CheckConsistency() also checks string content.
files:
Objects/unicodeobject.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1768,15 +1768,12 @@
unicode_fromascii(const unsigned char* s, Py_ssize_t size)
{
PyObject *unicode;
+ if (size == 1) {
#ifdef Py_DEBUG
- const unsigned char *p;
- const unsigned char *end = s + size;
- for (p=s; p < end; p++) {
- assert(*p < 128);
- }
-#endif
- if (size == 1)
+ assert(s[0] < 128);
+#endif
return get_latin1_char(s[0]);
+ }
unicode = PyUnicode_New(size, 127);
if (!unicode)
return NULL;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list