Closed lmazuel closed 4 years ago
Without the PR, trying to deserialize in a french VM:
>>> from msrest.serialization import Deserializer
>>> Deserializer.deserialize_rfc("Mon, 20 Nov 1995 19:12:08 -0500")
Traceback (most recent call last):
File "/home/lmazuel/rfctest/lib/python3.6/site-packages/msrest/serialization.py", line 1818, in deserialize_rfc
attr, "%a, %d %b %Y %H:%M:%S %Z")
File "/usr/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "/usr/lib/python3.6/_strptime.py", line 362, in _strptime
(data_string, format))
ValueError: time data 'Mon, 20 Nov 1995 19:12:08 -0500' does not match format '%a, %d %b %Y %H:%M:%S %Z'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lmazuel/rfctest/lib/python3.6/site-packages/msrest/serialization.py", line 1823, in deserialize_rfc
raise_with_traceback(DeserializationError, msg, err)
File "/home/lmazuel/rfctest/lib/python3.6/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
raise error.with_traceback(exc_traceback)
File "/home/lmazuel/rfctest/lib/python3.6/site-packages/msrest/serialization.py", line 1818, in deserialize_rfc
attr, "%a, %d %b %Y %H:%M:%S %Z")
File "/usr/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "/usr/lib/python3.6/_strptime.py", line 362, in _strptime
(data_string, format))
msrest.exceptions.DeserializationError: Cannot deserialize to rfc datetime object., ValueError: time data 'Mon, 20 Nov 1995 19:12:08 -0500' does not match format '%a, %d %b %Y %H:%M:%S %Z'
With the PR:
>>> from msrest.serialization import Deserializer
>>> Deserializer.deserialize_rfc("Mon, 20 Nov 1995 19:12:08 -0500")
datetime.datetime(1995, 11, 20, 19, 12, 8, tzinfo=<FixedOffset -5.0>)
Fix #192
Code inspired from the one I wrote for azure-core