pyopenapi / pyswagger

An OpenAPI (fka Swagger) client & converter in python, which is type-safe, dynamic, spec-compliant.
MIT License
385 stars 89 forks source link

OverflowError: mktime argument out of range #63

Closed labrys closed 8 years ago

labrys commented 8 years ago

Python Version: various 2.7.10+ and 3.3+ Platform: Windows 10 Traceback on import.

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    from pyswagger import SwaggerApp, SwaggerSecurity
  File "Python27\lib\site-packages\pyswagger\__init__.py", line 2, in <module>
    from .core import SwaggerApp, SwaggerSecurity
  File "Python27\lib\site-packages\pyswagger\core.py", line 4, in <module>
    from .primitives import SwaggerPrimitive
  File "Python27\lib\site-packages\pyswagger\primitives\__init__.py", line 14, in <module>
    from .render import Renderer
  File "Python27\lib\site-packages\pyswagger\primitives\render.py", line 98, in <module>
    max_date = time.mktime(datetime.date.max.timetuple())
OverflowError: mktime argument out of range
mission-liao commented 8 years ago

Hi, this is because the mktime on Windows would return -1 when the time-tuple refer to a time after (2038-01-19T03:14:07), refer to here for details.

A patch would work by modifying the line of code to

max_date = time.mktime(datetime.date(2038, 1, 19).timetuple())

...

max_datetime = time.mktime(datetime.datetime(2038, 1, 19).utctimetuple())

note: I didn't have a Windows platform to verify this patch, if it doesn't work, please let me know. And the corresponding fix would be included in next release.

labrys commented 8 years ago

@mission-liao I'm familiar with the issue and you're right that patch does allow the import to succeed, at least on Windows. I have not tested any further though.

mission-liao commented 8 years ago

Reopen it if it still fail on Windows

ChunPanWong commented 4 years ago

Dear all, as of today 18 May 2020 from HK, my Windows 10 Pro version 1909 can only start from 1971-01-01. However, my MacOS Catalina version 10.15.4 can start from 1900-01-01. Thank you all.