Replace deprecated datetime.datetime.utcnow - #480
Conversation
21641ad to
1e799b5
Compare
|
Related issue #473 |
71a2f91 to
46d284e
Compare
|
Duplicate of #475 and does a lot more - looks like you ran an auto-formatter or something changed a lot more lines than is relevant? |
That was due to the base commit to fix the lint check error. I removed that commit, because it was merged separately. |
The utcnow function was deprecated in Python 3.12[1]. Note that all datetime instances are kept non-timezone-aware to keep backword-compatibility. [1] https://docs.python.org/3.13/library/datetime.html#datetime.datetime.utcnow
|
Thank you for this, and apologies for how long it sat. There were three overlapping PRs open against #473 and #430 (this one, #475 and #491), all rewriting the same lines, so none could be merged alongside the others. I've combined them into #496, where your commit is preserved with you as the author. Your approach is the base of that branch: the Your commit is unmodified. It also ended up resolving #430: Closing here since the work continues in #496 — it's open for review, not merged yet. |
Combining #475 and #480 leaves one behavior change worth guarding: 475's unconditional v.astimezone(timezone.utc) treats a *naive* datetime as local time, shifting it by the machine's UTC offset. WebOb has always treated naive datetimes as UTC, and CI runs in UTC so the change is invisible there. Gate the conversion on v.tzinfo, keeping 475's fix for aware datetimes while leaving naive ones alone, and cover the naive/aware/date paths plus the new utcnow() helper.
The utcnow function was deprecated in Python 3.12[1].
Note that all datetime instances are kept non-timezone-aware to keep backword-compatibility.
[1] https://docs.python.org/3.13/library/datetime.html#datetime.datetime.utcnow