-
Notifications
You must be signed in to change notification settings - Fork 190
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
Python 3.13 deprecation of utcnow() #473
Comments
I have no concerns about any internal fixes - but I'm worried about areas where it'll hit the public api surface. |
Right… by moving from naive In the case of WebOb I think a transparent change would be e.g. from Lines 241 to 242 in 39d5af3
to if isinstance(v, timedelta):
v = (datetime.now(tz=timezone.utc) + v).replace(tzinfo=None) This would be a drop-in change to address the deprecation, but could probably be simplified case by case. Shouldn’t that address your concern about the public API surface? |
I guess I'm roping in the reason for the deprecation - not just how to workaround the warning. The goal of the deprecation is to get people to stop using naive datetimes and/or moving toward assuming that a naive datetime is "local" tz instead of UTC (because this is consistent with the stdlib apis and how they handle naive datetimes). So sure, if we are just tackling the warning then yeah you can simply replace usages of I was assuming you were also proposing the rest, in which you're actually changing the library to use tz-aware datetime objects which is a much bigger change. Can you clarify your proposal? |
To be clear - changing webob to expect tz-aware datetimes and expose tz-aware datetimes at the public api surface is secondary and much more controversial - we'll need to do that carefully. |
Agreed. But mixing aware and naive datetimes also requires care because they can’t be compared. So I think the question becomes:
|
Well let’s break it into two separate units of work if it's ok to you. But your choice. This datetime to tz-aware thing is like the python 3 change to Unicode but even more subtle imo. Personally to consider the second part I need to know more about what APIs are affected. I know cookies come to mind immediately and cache headers but perhaps there are more. |
Obviously we can continue to accept naive datetime objects and treat them as we always have (as utc for now??) which may be inconsistent with the stdlib but bw-compat at least. The biggest issue is where we expose a datetime for a user to consume because it will absolutely break for them if it becomes tz-aware. |
How about we start with a PR that replaces all deprecated naive
That should be drop-in change and would give us a good idea which places will be affected by the change. We can take this discussion from there. |
Yeah that sounds the most comfortable to me. |
Hello,
I’m seeing several deprecation warnings like
and other
utcnow()
related calls. Are there any plans to address this issue soon? Happy to provide a PR.The text was updated successfully, but these errors were encountered: