Skip to content

Commit

Permalink
Fixed parsing GCS updated datetime string because fromisoformat does …
Browse files Browse the repository at this point in the history
…not parse the used variation in Python <=3.10
  • Loading branch information
twarberg committed Nov 27, 2024
1 parent 865965b commit 83e06c1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rohmu/object_storage/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def initial_op(domain: Any) -> HttpRequest:
if (size := item.get("size")) is not None:
value["size"] = int(size)
if (updated := item.get("updated")) is not None:
value["last_modified"] = datetime.datetime.fromisoformat(updated)
value["last_modified"] = datetime.datetime.strptime(updated, "%Y-%m-%dT%H:%M:%S.%f%z")
if (md5 := item.get("md5Hash")) is not None:
value["md5"] = base64_to_hex(md5)
yield IterKeyItem(type=KEY_TYPE_OBJECT, value=value)
Expand Down
2 changes: 1 addition & 1 deletion test/object_storage/test_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def test_object_listed_when_missing_md5hash_size_and_updated() -> None:
sample_item,
{"size": 100, **sample_item},
{"md5Hash": base64.encodebytes(b"Missing md5Hash!"), **sample_item},
{"updated": "2023-11-20T16:18:00+00:00", **sample_item},
{"updated": "2023-11-20T16:18:00.000Z", **sample_item},
]
}

Expand Down

0 comments on commit 83e06c1

Please sign in to comment.