itsmeadarsh2008 / flpc

A Rust-based regex crate wrapper for Python3 to get faster performance. 👾
https://pypi.org/project/flpc/
MIT License
59 stars 1 forks source link

Unexpected error in version 0.2.4 #3

Closed KevinPD66 closed 2 months ago

KevinPD66 commented 2 months ago

I just upgraded flpc from 0.2.1 to 0.2.4 in my python 3.11 environment and for this code:

text = "The fox jumps over the dog. Poor dog!" pattern = flpc.compile(r'(\s|.|!)', flags=0) matches_iter = flpc.finditer(pattern, text) for match in matches_iter: span_start = match.start(0) span_end = match.end(0) print(span_start, span_end)

I know get an error message:

PanicException Traceback (most recent call last) Cell In [17], line 5 3 matches_iter = flpc.finditer(pattern, text) 4 for match in matches_iter: ----> 5 span_start = match.start(0) 6 span_end = match.end(0) 7 print(span_start, span_end)

PanicException: byte index 3 is out of bounds of

If I go back to 0.2.1 it's fine. Is there a dependency on my side I am not aware of?

itsmeadarsh2008 commented 2 months ago

It raised another bug due to a Unicode bug. However, it's fixed now. 👍 do: pip install --upgrade flpc

Python 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import flpc as re
>>> re.match = re.fmatch
>>> pattern = re.compile(r'(\s|.|!)', flags=0)
>>> text = "The fox jumps over the dog. Poor dog!"
>>> matches_iter = re.finditer(pattern, text)
>>> for i in matches_iter:
...  span_start = i.start(0)
...  span_end = i.end(0)
...  print(span_start,span_end)
...
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37