On 5/21/19 11:21 AM, Pino Toscano wrote: > datetime.date.fromisoformat() was introduced in Python 3.7, so provide > an alternative implementation for it with older Python versions. > > Fixes commit 5da3b8fdd836a55a58365718e93d0372fcc2bf0b. > --- > tests/test_dates.py | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/tests/test_dates.py b/tests/test_dates.py > index aa8db17..49df613 100644 > --- a/tests/test_dates.py > +++ b/tests/test_dates.py > @@ -2,14 +2,26 @@ > # See the COPYING file in the top-level directory. > > import datetime > +import re > +import sys > > from . import util > > > +if sys.version_info >= (3, 7): > + def _parse_iso_date(date_string): > + return datetime.date.fromisoformat(date_string) > +else: > + def _parse_iso_date(date_string): > + m = re.match("([0-9]{4})-([0-9]{2})-([0-9]{2})", date_string) > + assert m > + return datetime.date(int(m.group(1)), int(m.group(2)), int(m.group(3))) > + > + Why two implementations? Seems to me it just increases the odds that the impls diverge over time, reintroducing version specific issues I say just use the fallback impl Thanks, Cole > def _parse_date(date_string): > if not date_string: > return None > - return datetime.date.fromisoformat(date_string) > + return _parse_iso_date(date_string) > > > @util.os_parametrize('osxml', filter_dates=True) > - Cole _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo