FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Avoid usage of deprecated `datetime.datetime.utcfromtimestamp` in `pendulum.from_timestamp` by Taragolis · Pull Request #803 · python-pendulum/pendulum · GitHub

Avoid usage of deprecated datetime.datetime.utcfromtimestamp in pendulum.from_timestamp - #803

Closed
Taragolis wants to merge 1 commit into
python-pendulum:masterfrom
Taragolis:remove-deprecated-from-python-stdlib
Closed

Avoid usage of deprecated datetime.datetime.utcfromtimestamp in pendulum.from_timestamp#803
Taragolis wants to merge 1 commit into
python-pendulum:masterfrom
Taragolis:remove-deprecated-from-python-stdlib

Conversation

Copy link
Copy Markdown

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

datetime.datetime.utcfromtimestamp() is deprecated into the Python 3.12 as result current implementation raise warning message

/usr/local/lib/python3.12/site-packages/pendulum/__init__.py:295 DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC:

codspeed-hq Bot commented Feb 16, 2024

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #803 will not alter performance

Comparing Taragolis:remove-deprecated-from-python-stdlib (aac69cc) with master (3e3fec6)

Summary

✅ 1 untouched benchmarks

iakat added a commit to iakat/ircstates that referenced this pull request Mar 13, 2024
natikgadzhi mentioned this pull request Jun 1, 2024
2 tasks
Comment thread src/pendulum/__init__.py
dt = datetime(
dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond
)
dt = DateTime.fromtimestamp(timestamp, tz=UTC)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think the current suggestion is recursive and does not use the correct keyword:

Suggested change
dt = DateTime.fromtimestamp(timestamp, tz=UTC)
dt = _datetime.datetime.fromtimestamp(timestamp, tzinfo=UTC)

For the develop branch, the change must be done in pendulum/pendulum.py:491

dt = datetime.datetime.utcfromtimestamp(timestamp).replace(tzinfo=UTC)

to

dt = datetime.datetime.fromtimestamp(timestamp, tzinfo=UTC)

iakat added a commit to iakat/ircstates that referenced this pull request Sep 15, 2024

hozn commented Mar 11, 2025

Copy link
Copy Markdown

Also interested in this fix; is there help needed to get this through? (I see a failing test, but unsure if that's accurate as this is pretty old.)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL