Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
semiversus opened this issue Sep 18, 2016 · 2 comments
Closed
Labels

Comments

@semiversus
Copy link
Contributor

semiversus commented Sep 18, 2016

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.

asvetlov pushed a commit that referenced this issue Sep 19, 2016
* Update cookiejar.py

Fixeing issue #1188 . mktime depends on the underlying mktime from libc and on some embedded systems it uses only a 32bit time stamp which is reaching only to year 2038.

* Update CONTRIBUTORS.txt
asvetlov pushed a commit that referenced this issue Sep 19, 2016
* Update cookiejar.py

Fixeing issue #1188 . mktime depends on the underlying mktime from libc and on some embedded systems it uses only a 32bit time stamp which is reaching only to year 2038.

* Update CONTRIBUTORS.txt
@asvetlov
Copy link
Member

Fixed

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants