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

DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). #305

Closed
jiridanek opened this issue Dec 28, 2023 · 2 comments

Comments

@jiridanek
Copy link
Contributor

64: E           [2023-12-28 12:32:28 +0000] [5959] [INFO] Running on http://127.0.0.1:20885/ (CTRL + C to quit)
64: E            * Serving Quart app 'http2_server'
64: E            * Debug mode: False
64: E            * Please use an ASGI server (e.g. Hypercorn) directly in production
64: E            * Running on http://127.0.0.1:20885/ (CTRL + C to quit)
64: E           [2023-12-28 12:32:33 +0000] [5959] [INFO] 127.0.0.1:33108 GET / 2 200 3890 2700
64: E           [2023-12-28 12:32:33 +0000] [5959] [INFO] 127.0.0.1:33108 POST /myinfo 2 200 54 853
64: E           [2023-12-28 12:32:33 +0000] [5959] [INFO] 127.0.0.1:33108 GET /unavailable 2 404 207 936
64: E           [2023-12-28 12:32:33 +0000] [5959] [INFO] 127.0.0.1:33108 GET /test/500 2 500 265 766
64: E           [2023-12-28 12:32:34 +0000] [5959] [INFO] 127.0.0.1:33108 DELETE /myinfo/delete/22122 2 200 48 974
64: E           /usr/local/lib/python3.12/site-packages/quart/helpers.py:351: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
64: E             response.expires = datetime.utcnow() + timedelta(seconds=cache_timeout)
64: E           [2023-12-28 12:32:34 +0000] [5959] [INFO] 127.0.0.1:33108 GET /images/apache.jpg 2 200 5147 5234
64: E           [2023-12-28 12:32:34 +0000] [5959] [INFO] 127.0.0.1:33108 GET /images/balanced-routing.png 2 200 45011 4217
64: E           [2023-12-28 12:32:34 +0000] [5959] [INFO] 127.0.0.1:33108 GET / 2 200 3890 1232
64: E           [2023-12-28 12:32:34 +0000] [5959] [INFO] 127.0.0.1:33108 HEAD / 2 200 3890 1312
64: E           [2023-12-28 12:32:34 +0000] [5959] [INFO] 127.0.0.1:33108 PATCH /patch 2 200 42 951
64: E           [2023-12-28 12:32:34 +0000] [5959] [INFO] 127.0.0.1:33108 POST /myinfo 2 200 50 851
64: E           [2023-12-28 12:32:34 +0000] [5959] [INFO] 127.0.0.1:33108 PUT /myinfo 2 200 50 1069
64: E           [2023-12-28 12:32:34 +0000] [5959] [INFO] 127.0.0.1:33108 GET / 2 200 3890 1497
64: E           [2023-12-28 12:32:36 +0000] [5959] [INFO] 127.0.0.1:33108 GET / 2 200 3890 1551
64: E           [2023-12-28 12:32:36 +0000] [5959] [INFO] 127.0.0.1:33108 GET / 2 200 3890 1383
64: E           [2023-12-28 12:32:41 +0000] [5959] [INFO] 127.0.0.1:37272 GET / 2 200 3890 1553

Environment:

  • Python version: 3.12
  • Quart version: 0.19.4
@jiridanek
Copy link
Contributor Author

import datetime
print(datetime.datetime.utcnow())
print(datetime.datetime.now(datetime.timezone.utc))
print(datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None))
$ python3.12
Python 3.12.0 (main, Oct  2 2023, 00:00:00) [GCC 13.2.1 20230918 (Red Hat 13.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> print(datetime.datetime.utcnow())
<stdin>:1: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
2023-12-28 17:44:58.040299
>>> print(datetime.datetime.now(datetime.timezone.utc))
2023-12-28 17:44:58.040443+00:00
>>> print(datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None))
2023-12-28 17:44:58.575408

@pgjones
Copy link
Member

pgjones commented Jan 3, 2024

Fixed by ea7665c

@pgjones pgjones closed this as completed Jan 3, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants