wordnik / wordnik-python

Wordnik Python public library
227 stars 47 forks source link

DateTime parse error while querying word of the day #29

Open suyashb95 opened 5 years ago

suyashb95 commented 5 years ago

Trace

>>> wordoftheday_api = WordsApi.WordsApi(swagger.ApiClient(wordnik_api_key, wordnik_api))
>>> wordoftheday_api.getWordOfTheDay()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\Software\Python27\lib\site-packages\wordnik\WordsApi.py", line 141, in getWordOfTheDay
    responseObject = self.apiClient.deserialize(response, 'WordOfTheDay')
  File "E:\Software\Python27\lib\site-packages\wordnik\swagger.py", line 176, in deserialize
    "%Y-%m-%dT%H:%M:%S.%f"))
  File "E:\Software\Python27\lib\_strptime.py", line 332, in _strptime
    (data_string, format))
ValueError: time data '2019-04-25T03:00:00' does not match format '%Y-%m-%dT%H:%M:%S.%f'

This wasn't happening earlier, is it because of a recent update? Anyway, changing line 175 in swagger.py to setattr(instance, attr, datetime.datetime.strptime(value[:-5], "%Y-%m-%dT%H:%M:%S")) seems to fix it