graphql-python / graphene

GraphQL framework for Python
http://graphene-python.org/
MIT License
8.1k stars 828 forks source link

Dateparsing replacement in v3.4 is not 100% compatible #1580

Closed Yelinz closed 1 month ago

Yelinz commented 1 month ago

Datetime parsing breaks for certain formats on some python versions.

Python 3.10 fromisoformat accepted strings https://docs.python.org/3.10/library/datetime.html#datetime.datetime.fromisoformat

datetime.fromisoformat('2011-11-04')
datetime.fromisoformat('2011-11-04T00:05:23')
datetime.fromisoformat('2011-11-04 00:05:23.283')
datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')
datetime.fromisoformat('2011-11-04T00:05:23+04:00')   

Python 3.11 fromisoformat accepted strings https://docs.python.org/3.11/library/datetime.html#datetime.datetime.fromisoformat

datetime.fromisoformat('2011-11-04')
datetime.fromisoformat('20111104')
datetime.fromisoformat('2011-11-04T00:05:23')
datetime.fromisoformat('2011-11-04T00:05:23Z')
datetime.fromisoformat('20111104T000523')
datetime.fromisoformat('2011-W01-2T00:05:23.283')
datetime.fromisoformat('2011-11-04 00:05:23.283')
datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')
datetime.fromisoformat('2011-11-04T00:05:23+04:00')   

We ran into the issue by using Z for UTC timezone in the datetime strings (2011-11-04T00:05:23Z) with python 3.10. Where as before 3.4 it still worked with the same input.

Bug introduced by https://github.com/graphql-python/graphene/commit/17d09c8dedce36e2e0ea7dff4abf73bf3b39c541

erikwrede commented 1 month ago

Hey @Yelinz, thanks for the report. This one slipped through our tests and other checks. Sorry bout that. Will work on a fix& release for it this week.

erikwrede commented 1 month ago

Fixed in 3.4.1 🙂