botocore
botocore copied to clipboard
fix: convert utcnow() to now(UTC)
Fix deprecated datetime.datetime.utcnow() usage
Replace deprecated datetime.datetime.utcnow() calls with datetime.datetime.now(datetime.UTC) to resolve deprecation warnings and ensure future compatibility.
What changed:
Updated all instances of datetime.datetime.utcnow() to use datetime.datetime.now(datetime.UTC)
This change maintains identical functionality while using the recommended timezone-aware approach
Why:
datetime.datetime.utcnow() is deprecated in Python 3.12+ and scheduled for removal
The new approach explicitly uses timezone-aware datetime objects, which is the recommended best practice
Prevents deprecation warnings in logs and ensures forward compatibility
Testing:
Verified all datetime operations continue to work as expected No functional changes to application behavior
#3239 addresses this issue without introducing Python compatibility issues or serialization changes.
Unfortunately, I've been waiting for almost a year for a review from the devs.
Resolving in favor of https://github.com/boto/botocore/pull/3239. Thanks for the contribution though!