Skip to content

mktime in cookiejar.py reaches to far in to the future on some systems #1188

Closed
@semiversus

Description

Long story short

I'm using aiohttp on an embedded system (ARM v6) and this has a 32bit implementation of the unix time stamp in its libc. So the latest date to be calculated is 03:14:07 UTC on Tuesday, 19 January 2038 (see Y2K38 problem). cookiejar.py uses a date far in the future which is 1. January 2100 for MAX_TIME constant via time.mktime which depends on the underlying mktime from libc

As I don't see a reason for this far future 1. January of 2038 seems to be enough. Also using 2208985261.0 which is the result of time.mktime would do the same job.

Expected behaviour

Using aiohttp without OverflowError

Actual behaviour

Getting OverflowError on import aiohttp:

Python 3.5.2+ (default, Aug 30 2016, 19:08:42) 
[GCC 6.1.1 20160802] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import aiohttp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/aiohttp/__init__.py", line 11, in <module>
    from .connector import *  # noqa
  File "/usr/local/lib/python3.5/dist-packages/aiohttp/connector.py", line 17, in <module>
    from .client import ClientRequest
  File "/usr/local/lib/python3.5/dist-packages/aiohttp/client.py", line 20, in <module>
    from .cookiejar import CookieJar
  File "/usr/local/lib/python3.5/dist-packages/aiohttp/cookiejar.py", line 14, in <module>
    class CookieJar(AbstractCookieJar):
  File "/usr/local/lib/python3.5/dist-packages/aiohttp/cookiejar.py", line 30, in CookieJar
    MAX_TIME = time.mktime((2040, 1, 1, 1, 1, 1, 1, 1, 1,))  # so far in future
OverflowError: mktime argument out of range

Steps to reproduce

import aiohttp on a system with 32bit unix timestamp

Your environment

In the moment a raspberry pi with debian stretch.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions