summaryrefslogtreecommitdiffstats
path: root/Lib/sre_compile.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2004-05-07 07:18:13 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2004-05-07 07:18:13 (GMT)
commit7d9c6c7e8c1e381de7e96989c1332cf98d766f3a (patch)
tree207761f3b4b4024b877f26d9ee9ed7c849b6652c /Lib/sre_compile.py
parent156c49ad1c7c8d785f52c61ea05f2236da7e1325 (diff)
downloadcpython-7d9c6c7e8c1e381de7e96989c1332cf98d766f3a.zip
cpython-7d9c6c7e8c1e381de7e96989c1332cf98d766f3a.tar.gz
cpython-7d9c6c7e8c1e381de7e96989c1332cf98d766f3a.tar.bz2
Fix _sre.CODESIZE on 64-bit machines in UCS-4 mode. Fixes #931848.
Backported to 2.3.
Diffstat (limited to 'Lib/sre_compile.py')
-rw-r--r--Lib/sre_compile.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
index 7ddc097..fa21d95 100644
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -333,14 +333,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)]