From d7fc2b9a725c728ad748e0d2914e5e2d0505084c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Fri, 7 May 2004 07:16:33 +0000 Subject: [PATCH] Fix _sre.CODESIZE on 64-bit machines in UCS-4 mode. Fixes #931848. --- Lib/sre_compile.py | 8 +++++--- Misc/NEWS | 2 ++ Modules/sre.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) 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 -- 2.47.3