This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients pitrou, vstinner
Date 2011-10-12.00:11:44
SpamBayes Score 0.00012685778
Marked as misclassified No
Message-id <1318378305.18.0.54202768.issue13155@psf.upfronthosting.co.za>
In-reply-to
Content
> Ok, updated patch.

"ret = ~mask + 1;" looks wrong: (~0xFFFFFF80+1) gives 128, not 127. I don't see why you need:

+    if (ret < 128)
+        return 127;
+    if (ret < 256)
+        return 255;

#undef ASCII_CHAR_MASK should be #undef UCS1_ASCII_CHAR_MASK


#error Invalid STRINGLIB_SIZEOF_CHAR (must be 1, 2 or 4)
should be
#error Invalid STRINGLIB_SIZEOF_CHAR (must be 2 or 4)

Why do you need these forward declarations? It's maybe related to another patch?

 static PyObject *
+unicode_fromascii(const unsigned char *s, Py_ssize_t size);
+static PyObject *
+_PyUnicode_FromUCS1(const unsigned char *s, Py_ssize_t size);
+static PyObject *
+_PyUnicode_FromUCS2(const Py_UCS2 *s, Py_ssize_t size);
+static PyObject *
+_PyUnicode_FromUCS4(const Py_UCS4 *s, Py_ssize_t size);

(You kept Py_UCS4 for "Py_UCS4 bits", but Py_UCS4 is maybe just fine.)

By the way, your function rocks :-) Use bit masks is a great idea, especially your "bits = p[0] | p[1] | p[2] | p[3]" "hack".
History
Date User Action Args
2011-10-12 00:11:45vstinnersetrecipients: + vstinner, pitrou
2011-10-12 00:11:45vstinnersetmessageid: <1318378305.18.0.54202768.issue13155@psf.upfronthosting.co.za>
2011-10-12 00:11:44vstinnerlinkissue13155 messages
2011-10-12 00:11:44vstinnercreate