-
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
Replace to-be-deprecated utcnow() datetime calls with aware now() calls #475
base: main
Are you sure you want to change the base?
Replace to-be-deprecated utcnow() datetime calls with aware now() calls #475
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments below to continue the conversation from issue #473.
src/webob/cookies.py
Outdated
v = datetime.utcnow() + v | ||
v = datetime.now(tz=zoneinfo.ZoneInfo("UTC")) + v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string formatting below doesn’t care that the datetime object is aware here.
src/webob/cookies.py
Outdated
if isinstance(v, datetime): | ||
v = v.astimezone(zoneinfo.ZoneInfo("UTC")).timetuple() | ||
elif isinstance(v, date): | ||
v = v.timetuple() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function can receive bytes
, str
, int
but it doesn’t have an else branch to catch any other unexpected type. If for some reason a datetime is passed in then we’ll want to make sure it’s in UTC, hence the adjustment. Also, unless a date object is passed in there shouldn’t be a need to handle those but cookies should always contain a date & time AFAIK.
src/webob/response.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All utcnow()
are replaced and continue to produce naive datetime objects in UTC.
|
7b13071
to
dcd915a
Compare
Sigh 🤦🏻♂️ Consider that a magnificent brain fart on my side. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@mmerickel what do you think of the above comments/questions, esp #475 (comment)? |
As per issue #473
I didn’t add tests yet, see my comments below.
Still need to format the code, but it looks like Windows tests fail because, I suspect, of this data source discrepancy.