Open mrabarnett opened 5 years ago
Original comment by Matthew Barnett (Bitbucket: mrabarnett, GitHub: mrabarnett).
Here’s a script you could try to ‘clean’ the regex installation:
# Script to 'clean' an installation of the regex module.
from glob import glob
from os import remove
from os.path import dirname, isdir, join
import regex
site_folder = dirname(dirname(regex.__file__))
del regex
old_files = glob(join(site_folder, 'regex.*')) + glob(join(site_folder, '_regex.*'))
if isdir(join(site_folder, 'regex')):
if old_files:
for path in old_files:
print(f'Found old file {path}')
# Uncomment the next line to remove the old file.
#remove(path)
else:
print('No old files')
else:
print('New regex not found')
Original comment by Matthew Barnett (Bitbucket: mrabarnett, GitHub: mrabarnett).
I reduced it down to:
import regex
print(regex.match(r'(?:(?=(e)?)\1){e<=1}', ' '))
which still crashed.
Original comment by Bruno BC (Bitbucket: [Bruno BC](https://bitbucket.org/Bruno BC), ).
Thanks Matthew, I will try that.
Did you get the chance to test any other expressions, because this is the only one that crashes in my system. I can do other fuzzy searches without problems.
Regards,
Bruno
Original comment by Matthew Barnett (Bitbucket: mrabarnett, GitHub: mrabarnett).
I think the problem might be that I re-organised the files previously and if you install a new version of regex some of the old files get left behind, which somehow works most of the time but sometimes doesn’t.
I found that problem on the Raspberry Pi and fixed it by uninstalling regex, removing any remaining files related to the regex module from the site-packages subfolder of Python, and then re-installing regex.
Original comment by Matthew Barnett (Bitbucket: mrabarnett, GitHub: mrabarnett).
I was thinking about how to test it when it doesn’t crash on my machine and it occurred to me that I do have another machine I could test it on: a Raspberry Pi. It crashes!
Original comment by Bruno BC (Bitbucket: [Bruno BC](https://bitbucket.org/Bruno BC), ).
Hello Matthew,
I cannot get past the print(pattern.search('al, ')) command. As soon as I execute this command, the kernel crashes.
This is a print-screen of my third try. (note: “Python dejó de funcionar” means Python stopped working)
Thanks,
Bruno
Original comment by Matthew Barnett (Bitbucket: mrabarnett, GitHub: mrabarnett).
Could you try these at the Python prompt to confirm what you’re getting:
import regex
pattern = regex.compile(r'(?e)(?:(?:(?=(?P<if_2_3>expression1\W+)?)(?P=if_2_3))?(?(if_2_3)expression2|expression3)){e<=1}')
# Should print None.
print(pattern.search('al, '))
s = pattern.finditer('al, ')
# Should raise StopIteration.
next(s)
pattern = regex.compile(r'(?:(?:(?=(?P<if_2_3>expression1\W+)?)(?P=if_2_3))?(?(if_2_3)expression2|expression3)){e<=1}')
# Should print None.
print(pattern.search('al, '))
s = pattern.finditer('al, ')
# Should raise StopIteration.
next(s)
Original comment by Bruno BC (Bitbucket: [Bruno BC](https://bitbucket.org/Bruno BC), ).
Thanks for the interest Matthew.
I can confirm that I still have the bug. It is a very strange bug. It won’t happen if I change the string to search or if I execute without fuzzy options. It must be something related to my installation.
This is the windows event log crash report:
-
-
-
If you are interested (and tell me how), I can try to generate some additional log from within the execution script.
Regards,
B.
Original comment by Matthew Barnett (Bitbucket: mrabarnett, GitHub: mrabarnett).
Just tried it (Windows 10 64-bit, Python 3.7). No crash. Tried Python 3.6 too. No crash.
Original comment by Talha Moosani (Bitbucket: [Talha Moosani](https://bitbucket.org/Talha Moosani), ).
Hi Matthew, I am having the same issue with the below regex.
mypattern = r'(?<=Ves\/Voy\/Dir[\s]*)([\D]+[\s]*[\D]+)[\s]([\w]+.+)'
matchNum = re.search(mypattern,text,re.IGNORECASE)
Original comment by Matthew Barnett (Bitbucket: mrabarnett, GitHub: mrabarnett).
What is the value of ‘text'? Without that I’m unable to help. I need a complete example that shows the problem, ideally the smallest example that shows it.
For the heck of it, I checked all the examples with the latest version of regex (now that #525 is fixed) in CPython 3.12 64-bit and none crash, all give the expected outputs. Perhaps this problems is related.
Original report by Anonymous.
The following regex fuzzy search will crash the Python kernel and give a message: “Kernel died, restarting”.
It took me a long time to figure out exactly what were the exact crash conditions, and I also found out that there was an error in the regex expression since the ? in expression1\W+)? doesn’t make any sense, still, the module should crash the whole kernel.
I am using version '2.5.33' 64 bits for python 3.7 in windows 10 64, installed manually from wheel file. These are the most important package versions:
P.S. Thanks for the great module.