Merge heads.
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 9c06ec8..880a5f0 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -347,7 +347,7 @@
memchr(in_str, '\n', PyUnicode_KIND_SIZE(kind, len)) != NULL) {
Py_ssize_t i = 0;
for (;;) {
- Py_UNICODE c;
+ Py_UCS4 c;
/* Fast loop for non-control characters */
while (PyUnicode_READ(kind, in_str, i) > '\n')
i++;
@@ -1570,7 +1570,7 @@
}
-/* NOTE: `end` must point to the real end of the Py_UNICODE storage,
+/* NOTE: `end` must point to the real end of the Py_UCS4 storage,
that is to the NUL character. Otherwise the function will produce
incorrect results. */
static char *
@@ -1614,7 +1614,7 @@
for (;;) {
Py_UCS4 ch;
/* Fast path for non-control chars. The loop always ends
- since the Py_UNICODE storage is NUL-terminated. */
+ since the Unicode string is NUL-terminated. */
while (PyUnicode_READ(kind, s, 0) > '\r')
s += size;
if (s >= end) {
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 443150d..c685bae 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -163,15 +163,15 @@
/* unicode-specific character predicates */
-#define SRE_UNI_IS_DIGIT(ch) Py_UNICODE_ISDECIMAL((Py_UNICODE)(ch))
-#define SRE_UNI_IS_SPACE(ch) Py_UNICODE_ISSPACE((Py_UNICODE)(ch))
-#define SRE_UNI_IS_LINEBREAK(ch) Py_UNICODE_ISLINEBREAK((Py_UNICODE)(ch))
-#define SRE_UNI_IS_ALNUM(ch) Py_UNICODE_ISALNUM((Py_UNICODE)(ch))
-#define SRE_UNI_IS_WORD(ch) (SRE_UNI_IS_ALNUM((ch)) || (ch) == '_')
+#define SRE_UNI_IS_DIGIT(ch) Py_UNICODE_ISDECIMAL(ch)
+#define SRE_UNI_IS_SPACE(ch) Py_UNICODE_ISSPACE(ch)
+#define SRE_UNI_IS_LINEBREAK(ch) Py_UNICODE_ISLINEBREAK(ch)
+#define SRE_UNI_IS_ALNUM(ch) Py_UNICODE_ISALNUM(ch)
+#define SRE_UNI_IS_WORD(ch) (SRE_UNI_IS_ALNUM(ch) || (ch) == '_')
static unsigned int sre_lower_unicode(unsigned int ch)
{
- return (unsigned int) Py_UNICODE_TOLOWER((Py_UNICODE)(ch));
+ return (unsigned int) Py_UNICODE_TOLOWER(ch);
}
LOCAL(int)
@@ -1674,7 +1674,7 @@
return ptr;
}
- /* get pointer to string buffer */
+ /* get pointer to byte string buffer */
view.len = -1;
buffer = Py_TYPE(string)->tp_as_buffer;
if (!buffer || !buffer->bf_getbuffer ||
@@ -1702,8 +1702,6 @@
if (PyBytes_Check(string) || bytes == size)
charsize = 1;
- else if (bytes == (Py_ssize_t) (size * sizeof(Py_UNICODE)))
- charsize = sizeof(Py_UNICODE);
else {
PyErr_SetString(PyExc_TypeError, "buffer size mismatch");
return NULL;
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index d294cd6..72e5815 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -1147,7 +1147,7 @@
\n\
Remove all items from B.");
-static PyObject *
+static PyObject *
bytearray_clear(PyByteArrayObject *self)
{
if (PyByteArray_Resize((PyObject *)self, 0) < 0)
@@ -2629,7 +2629,7 @@
Example: bytearray.fromhex('B9 01EF') -> bytearray(b'\\xb9\\x01\\xef').");
static int
-hex_digit_to_int(Py_UNICODE c)
+hex_digit_to_int(Py_UCS4 c)
{
if (c >= 128)
return -1;
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index b77d693..fa0e8c2 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -593,7 +593,7 @@
quote = '"';
if (squotes && quote == '\'')
newsize += squotes;
-
+
if (newsize > (PY_SSIZE_T_MAX - sizeof(PyUnicodeObject) - 1)) {
PyErr_SetString(PyExc_OverflowError,
"bytes object is too large to make repr");
@@ -2330,7 +2330,7 @@
Example: bytes.fromhex('B9 01EF') -> b'\\xb9\\x01\\xef'.");
static int
-hex_digit_to_int(Py_UNICODE c)
+hex_digit_to_int(Py_UCS4 c)
{
if (c >= 128)
return -1;
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 08f5065..428914f 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -148,15 +148,6 @@
return v;
}
-static int
-_ustrlen(Py_UNICODE *u)
-{
- int i = 0;
- Py_UNICODE *v = u;
- while (*v != 0) { i++; v++; }
- return i;
-}
-
static PyObject *
do_mktuple(const char **p_format, va_list *p_va, int endchar, int n, int flags)
{
@@ -269,7 +260,7 @@
}
else {
if (n < 0)
- n = _ustrlen(u);
+ n = Py_UNICODE_strlen(u);
v = PyUnicode_FromUnicode(u, n);
}
return v;