Skip to content

Commit 29de41a

Browse files
authored
Merge pull request #937 from mathics/Python2-divide-incompatibility
Fix runtime bugs seen from GS3.m in per_expr()
2 parents ee26b45 + 6baa1bb commit 29de41a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

mathics/core/pattern.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,17 +322,21 @@ def per_expr(yield_expr, expr_groups, sum=0):
322322

323323
if expr_groups:
324324
expr, count = expr_groups.popitem()
325-
max_per_pattern = count / len(patterns)
325+
max_per_pattern = count // len(patterns)
326326
for per_pattern in range(max_per_pattern, -1, -1):
327327
for next in per_expr( # nopep8
328328
expr_groups, sum + per_pattern):
329329
yield_expr([expr] * per_pattern + next)
330330
else:
331331
if sum >= match_count[0]:
332332
yield_expr([])
333+
# Until we learn that the below is incorrect, we'll return basically no match.
334+
yield None
333335

334336
# for sequence in per_expr(expr_groups.items()):
335337
def yield_expr(sequence):
338+
# FIXME: this call is wrong and needs a
339+
# wrapper_function as the 1st parameter.
336340
wrappings = self.get_wrappings(
337341
sequence, match_count[1], expression, attributes)
338342
for wrapping in wrappings:

0 commit comments

Comments
 (0)