botocore icon indicating copy to clipboard operation
botocore copied to clipboard

fix: convert utcnow() to now(UTC)

Open nicolapace opened this issue 5 months ago • 1 comments

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

nicolapace avatar Jun 11 '25 12:06 nicolapace

#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.

kurtmckee avatar Jun 11 '25 20:06 kurtmckee

Resolving in favor of https://github.com/boto/botocore/pull/3239. Thanks for the contribution though!

nateprewitt avatar Aug 01 '25 20:08 nateprewitt