ubuntu-advantage: mention that fromisoformat can handle Z suffix in Python >= 3.11

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2024-04-25 15:53:39 +02:00
parent 26bc08b694
commit 4695078c84
1 changed files with 2 additions and 2 deletions

View File

@ -328,8 +328,8 @@ class UAInterface:
info = await self.get_subscription_status(token) info = await self.get_subscription_status(token)
# Sometimes, a time zone offset of 0 is replaced by the letter Z. This # Sometimes, a time zone offset of 0 is replaced by the letter Z. This
# is specified in RFC 3339 but not supported by fromisoformat. # is specified in RFC 3339 but not supported by fromisoformat before
# See https://bugs.python.org/issue35829 # Python 3.11. See https://bugs.python.org/issue35829
expiration = dt.fromisoformat(info["expires"].replace("Z", "+00:00")) expiration = dt.fromisoformat(info["expires"].replace("Z", "+00:00"))
if expiration.timestamp() <= dt.utcnow().timestamp(): if expiration.timestamp() <= dt.utcnow().timestamp():
raise ExpiredTokenError(token, expires=info["expires"]) raise ExpiredTokenError(token, expires=info["expires"])