summaryrefslogtreecommitdiffstats
path: root/Modules/_sre.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-09-29 01:27:47 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-09-29 01:27:47 (GMT)
commit0058b8603f65279d5e777b0c85b05565c5e98682 (patch)
treeaa487ae918578b203240ec49e11c39472ccbb999 /Modules/_sre.c
parent9d3579b7d68816dc35da47a6a972e57f6c936dea (diff)
downloadcpython-0058b8603f65279d5e777b0c85b05565c5e98682.zip
cpython-0058b8603f65279d5e777b0c85b05565c5e98682.tar.gz
cpython-0058b8603f65279d5e777b0c85b05565c5e98682.tar.bz2
_sre: don't use Py_UNICODE anymore
* Downcasting from Py_UCS4 to Py_UNICODE is wrong is Py_UNICODE is 16-bit wchar_t * Remove old special case in getstring(), unicode is now handled separetely
Diffstat (limited to 'Modules/_sre.c')
-rw-r--r--Modules/_sre.c16
1 files changed, 7 insertions, 9 deletions
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 @@ static unsigned int sre_lower_locale(unsigned int ch)
/* 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 @@ getstring(PyObject* string, Py_ssize_t* p_length,
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 @@ getstring(PyObject* string, Py_ssize_t* p_length,
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;