Skip to content

Commit 7ccd2d8

Browse files
committed
re-pcre: Actually fix compatibility with big-endian systems.
"big" argument to b"".from_bytes(..., "big") isn't really supported by MicroPython, so use array as a buffer.
1 parent 6e0f020 commit 7ccd2d8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

re-pcre/re.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def __init__(self, compiled_ptn):
6666

6767
def search(self, s, pos=0, endpos=-1, _flags=0):
6868
assert endpos == -1, "pos: %d, endpos: %d" % (pos, endpos)
69-
buf = bytes(4)
69+
buf = array.array('i', [0])
7070
pcre_fullinfo(self.obj, None, PCRE_INFO_CAPTURECOUNT, buf)
71-
cap_count = int.from_bytes(buf, sys.byteorder)
71+
cap_count = buf[0]
7272
ov = array.array('i', [0, 0, 0] * (cap_count + 1))
7373
num = pcre_exec(self.obj, None, s, len(s), pos, _flags, ov, len(ov))
7474
if num == -1:

0 commit comments

Comments
 (0)