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

replace "datetime.utcfromtimestamp" to avoid deprecation warnings with Python 3.12 #7715

Merged
merged 1 commit into from
Jul 6, 2023
Merged

replace "datetime.utcfromtimestamp" to avoid deprecation warnings with Python 3.12 #7715

merged 1 commit into from
Jul 6, 2023

Conversation

FelixSchwarz
Copy link
Contributor

datetime.utcfromtimestamp is deprecated in Python 3.12:

src/borg/testsuite/helpers.py:1218: DeprecationWarning: datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.fromtimestamp(timestamp, datetime.UTC).
    assert datetime.utcfromtimestamp(safe_ns(beyond_y10k) / 1000000000) > datetime(2038, 1, 1)

I added a custom helper with emulates the behavior of datetime.utcnow to avoid the deprecation warning. My idea was that creating tz-aware datetime instances creates longer code lines and reduces readability.

@codecov-commenter
Copy link

codecov-commenter commented Jul 6, 2023

Codecov Report

Merging #7715 (ae0b3d2) into master (e695683) will decrease coverage by 0.32%.
The diff coverage is n/a.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #7715      +/-   ##
==========================================
- Coverage   83.79%   83.47%   -0.32%     
==========================================
  Files          66       66              
  Lines       11893    11893              
  Branches     2153     2153              
==========================================
- Hits         9966     9928      -38     
- Misses       1356     1385      +29     
- Partials      571      580       +9     

see 8 files with indirect coverage changes

@ThomasWaldmann ThomasWaldmann merged commit 29d73f4 into borgbackup:master Jul 6, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants