Open
Description
Using either 32-bit or 64-bit PythonScript v1.5.4, I get a crash when running the following code:
overall_match_number = 0
def match_found(m):
global overall_match_number
num_groups = len(m.groups())
for g in xrange(num_groups + 1):
print(overall_match_number, num_groups, g, m.start(g), m.end(g), m.span(g), m.group(g), m.groups(), m.lastindex, m.expand(r'hello \1 there'), m.lastindex)
overall_match_number += 1
# X7a X99b X23 zzzzz X39c
def main():
matches_list = []
editor.research('X([0-9]+)([abc]?)', lambda m: matches_list.append(m))
for m in matches_list: match_found(m)
main()
If I change main()
to be:
def main():
editor.research('X([0-9]+)([abc]?)', match_found)
Then the code runs as intended and produces proper output:
0 2 0 3831 3834 (3831, 3834) X7a ('7', 'a') 2 hello 7 there 2
0 2 1 3832 3833 (3832, 3833) 7 ('7', 'a') 2 hello 7 there 2
0 2 2 3833 3834 (3833, 3834) a ('7', 'a') 2 hello 7 there 2
1 2 0 3835 3839 (3835, 3839) X99b ('99', 'b') 2 hello 99 there 2
1 2 1 3836 3838 (3836, 3838) 99 ('99', 'b') 2 hello 99 there 2
1 2 2 3838 3839 (3838, 3839) b ('99', 'b') 2 hello 99 there 2
2 2 0 3840 3843 (3840, 3843) X23 ('23', '') 2 hello 23 there 2
2 2 1 3841 3843 (3841, 3843) 23 ('23', '') 2 hello 23 there 2
2 2 2 3843 3843 (3843, 3843) ('23', '') 2 hello 23 there 2
3 2 0 3850 3854 (3850, 3854) X39c ('39', 'c') 2 hello 39 there 2
3 2 1 3851 3853 (3851, 3853) 39 ('39', 'c') 2 hello 39 there 2
3 2 2 3853 3854 (3853, 3854) c ('39', 'c') 2 hello 39 there 2
so I think it has something to do with the "lambda"ing??
Anyway, the crash is a hard one, and gives me this box: