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

Fix OverflowError with 32-bit (signed) time_t #4873

Merged
merged 2 commits into from
Oct 16, 2020
Merged

Fix OverflowError with 32-bit (signed) time_t #4873

merged 2 commits into from
Oct 16, 2020

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Jul 20, 2020

Fix the package to work on 32-bit platforms (i386, arm) that use 32-bit
signed time_t. This means changing TestCookieJarSafe.test_expires() to
use an earlier arbitrary date, and adjusting CookieJar to use MAX_TIME
that fits in time_t.

For the latter purpose, we try to convert datetime.max into timestamp
and if it fails, we make date from a timestamp matching max unsigned
int32. This is far from perfect but apparently there's no trivial way
of getting max time_t value from inside Python, and it should cover all
the common platforms.

Fixes #4515

What do these changes do?

Are there changes in behavior for the user?

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

@mgorny mgorny requested a review from asvetlov as a code owner July 20, 2020 07:24
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Jul 20, 2020
Fix the package to work on 32-bit platforms (i386, arm) that use 32-bit
signed time_t.  This means changing TestCookieJarSafe.test_expires() to
use an earlier arbitrary date, and adjusting CookieJar to use MAX_TIME
that fits in time_t.

For the latter purpose, we try to convert datetime.max into timestamp
and if it fails, we make date from a timestamp matching max unsigned
int32.  This is far from perfect but apparently there's no trivial way
of getting max time_t value from inside Python, and it should cover all
the common platforms.

Fixes #4515
@mgorny mgorny requested a review from webknjaz as a code owner July 20, 2020 07:25
@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2020

Codecov Report

Merging #4873 into master will increase coverage by 0.01%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4873      +/-   ##
==========================================
+ Coverage   97.58%   97.59%   +0.01%     
==========================================
  Files          43       43              
  Lines        8932     8938       +6     
  Branches     1406     1406              
==========================================
+ Hits         8716     8723       +7     
  Misses         96       96              
+ Partials      120      119       -1     
Impacted Files Coverage Δ
aiohttp/cookiejar.py 99.16% <77.77%> (-0.84%) ⬇️
aiohttp/pytest_plugin.py 97.51% <0.00%> (+1.86%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d296d5...19f3815. Read the comment docs.

@asvetlov asvetlov merged commit 57c1f1a into aio-libs:master Oct 16, 2020
@asvetlov
Copy link
Member

Thanks!

@github-actions
Copy link
Contributor

💔 Backport was not successful

The PR was attempted backported to the following branches:

  • ❌ 3.7: Commit could not be cherrypicked due to conflicts

asvetlov added a commit that referenced this pull request Oct 16, 2020
Fix the package to work on 32-bit platforms (i386, arm) that use 32-bit
signed time_t.  This means changing TestCookieJarSafe.test_expires() to
use an earlier arbitrary date, and adjusting CookieJar to use MAX_TIME
that fits in time_t.

For the latter purpose, we try to convert datetime.max into timestamp
and if it fails, we make date from a timestamp matching max unsigned
int32.  This is far from perfect but apparently there's no trivial way
of getting max time_t value from inside Python, and it should cover all
the common platforms.

Fixes #4515

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
asvetlov added a commit that referenced this pull request Oct 16, 2020
Fix the package to work on 32-bit platforms (i386, arm) that use 32-bit
signed time_t.  This means changing TestCookieJarSafe.test_expires() to
use an earlier arbitrary date, and adjusting CookieJar to use MAX_TIME
that fits in time_t.

For the latter purpose, we try to convert datetime.max into timestamp
and if it fails, we make date from a timestamp matching max unsigned
int32.  This is far from perfect but apparently there's no trivial way
of getting max time_t value from inside Python, and it should cover all
the common platforms.

Fixes #4515

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

time in cookiejar.py tests reaches to far in to the future on some systems
3 participants