-
Notifications
You must be signed in to change notification settings - Fork 163
Closed
Labels
api: storageIssues related to the googleapis/python-storage API.Issues related to the googleapis/python-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- OS type and version: centos 6
- Python version: 3.7
google-cloud-storage
version: 1.34.0
Steps to reproduce
- Load a blob
- Set the
custom_time
field to a datetime object with 0 microseconds - patch the object with the changes, and then reload the object
- Access the
custom_time
field and observe the value error
Code example
blob = Blob(mybucket, objectname)
blob.reload()
blob.custom_time = datetime(year=2000, month = 1, day = 13, hour = 13, minute = 1, second = 0, microsecond = 0)
blob.patch()
blob.reload()
blob.custom_time
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 3773, in custom_time
return _rfc3339_to_datetime(value)_rfc3339_to_datetime
File "/usr/local/lib/python3.7/site-packages/google/cloud/_helpers.py", line 286, in _rfc3339_to_datetime
return datetime.datetime.strptime(dt_str, _RFC3339_MICROS).replace(tzinfo=UTC)
File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
(data_string, format))
ValueError("time data '2000-01-13T13:01:00Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'")
As compared to a working example:
blob.custom_time = datetime(year=2000, month = 1, day = 13, hour = 14, minute = 2, second = 0, microsecond = 10)
blob.patch()
blob.reload()
blob.custom_time
datetime.datetime(2000, 1, 13, 14, 2, 0, 10, tzinfo=<UTC>)
Stack trace
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 3773, in custom_time
return _rfc3339_to_datetime(value)_rfc3339_to_datetime
File "/usr/local/lib/python3.7/site-packages/google/cloud/_helpers.py", line 286, in _rfc3339_to_datetime
return datetime.datetime.strptime(dt_str, _RFC3339_MICROS).replace(tzinfo=UTC)
File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
(data_string, format))
ValueError("time data '2000-01-13T13:01:00Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'")
oittaa
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the googleapis/python-storage API.Issues related to the googleapis/python-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.