From: Martin v. Löwis Date: Fri, 7 May 2004 07:16:33 +0000 (+0000) Subject: Fix _sre.CODESIZE on 64-bit machines in UCS-4 mode. Fixes #931848. X-Git-Tag: v2.3.4c1~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d7fc2b9a725c728ad748e0d2914e5e2d0505084c;p=thirdparty%2FPython%2Fcpython.git Fix _sre.CODESIZE on 64-bit machines in UCS-4 mode. Fixes #931848. --- diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index 8a26a0f43d2f..6710ae91c081 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -308,14 +308,16 @@ def _optimize_unicode(charset, fixup): block = block + 1 data = data + _mk_bitmap(chunk) header = [block] - if MAXCODE == 65535: + if _sre.CODESIZE == 2: code = 'H' else: - code = 'L' + code = 'I' # Convert block indices to byte array of 256 bytes mapping = array.array('b', mapping).tostring() # Convert byte array to word array - header = header + array.array(code, mapping).tolist() + mapping = array.array(code, mapping) + assert mapping.itemsize == _sre.CODESIZE + header = header + mapping.tolist() data[0:0] = header return [(BIGCHARSET, data)] diff --git a/Misc/NEWS b/Misc/NEWS index c422b227bb83..9fa7b9b79107 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -42,6 +42,8 @@ Core and builtins Library ------- +- Bug #931848: Fix _sre.CODESIZE on 64-bit machines in UCS-4 mode. + - Bug #938076: Consider output encoding in XMLGenerator. - Bug #936637: Properly delegate startElementNS in saxutils.XMLFilterBase. diff --git a/Modules/sre.h b/Modules/sre.h index a7fdfbab647f..d416c3d1eb80 100644 --- a/Modules/sre.h +++ b/Modules/sre.h @@ -16,7 +16,7 @@ /* size of a code word (must be unsigned short or larger, and large enough to hold a Py_UNICODE character) */ #ifdef Py_UNICODE_WIDE -#define SRE_CODE unsigned long +#define SRE_CODE Py_UCS4 #else #define SRE_CODE unsigned short #endif