From c89048d8063b5961ceec1f75e7ddf79992f08c5b Mon Sep 17 00:00:00 2001 From: Benjamin Cutler Date: Mon, 4 Dec 2023 14:44:08 -0700 Subject: [PATCH] fix Python < 3.10 --- tracker/models/event.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tracker/models/event.py b/tracker/models/event.py index ceb1b9ed0..a4d8afb21 100644 --- a/tracker/models/event.py +++ b/tracker/models/event.py @@ -21,6 +21,19 @@ from .fields import TimestampField from .util import LatestEvent +# TODO: remove when 3.10 is oldest supported version + +try: + from itertools import pairwise +except ImportError: + + def pairwise(iterable): + # pairwise('ABCDEFG') --> AB BC CD DE EF FG + a, b = itertools.tee(iterable) + next(b, None) + return zip(a, b) + + __all__ = [ 'Event', 'PostbackURL', @@ -547,7 +560,7 @@ def clean(self): 'order': 'Next anchor in the order would occur before this one' } ) - for c, n in itertools.pairwise( + for c, n in pairwise( itertools.chain( [self], SpeedRun.objects.filter(