Kaydet (Commit) d7fc2b9a authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Fix _sre.CODESIZE on 64-bit machines in UCS-4 mode. Fixes #931848.

üst d532acd6
...@@ -308,14 +308,16 @@ def _optimize_unicode(charset, fixup): ...@@ -308,14 +308,16 @@ def _optimize_unicode(charset, fixup):
block = block + 1 block = block + 1
data = data + _mk_bitmap(chunk) data = data + _mk_bitmap(chunk)
header = [block] header = [block]
if MAXCODE == 65535: if _sre.CODESIZE == 2:
code = 'H' code = 'H'
else: else:
code = 'L' code = 'I'
# Convert block indices to byte array of 256 bytes # Convert block indices to byte array of 256 bytes
mapping = array.array('b', mapping).tostring() mapping = array.array('b', mapping).tostring()
# Convert byte array to word array # 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 data[0:0] = header
return [(BIGCHARSET, data)] return [(BIGCHARSET, data)]
......
...@@ -42,6 +42,8 @@ Core and builtins ...@@ -42,6 +42,8 @@ Core and builtins
Library Library
------- -------
- Bug #931848: Fix _sre.CODESIZE on 64-bit machines in UCS-4 mode.
- Bug #938076: Consider output encoding in XMLGenerator. - Bug #938076: Consider output encoding in XMLGenerator.
- Bug #936637: Properly delegate startElementNS in saxutils.XMLFilterBase. - Bug #936637: Properly delegate startElementNS in saxutils.XMLFilterBase.
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
/* size of a code word (must be unsigned short or larger, and /* size of a code word (must be unsigned short or larger, and
large enough to hold a Py_UNICODE character) */ large enough to hold a Py_UNICODE character) */
#ifdef Py_UNICODE_WIDE #ifdef Py_UNICODE_WIDE
#define SRE_CODE unsigned long #define SRE_CODE Py_UCS4
#else #else
#define SRE_CODE unsigned short #define SRE_CODE unsigned short
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment