boto / botocore

The low-level, core functionality of boto3 and the AWS CLI.
Apache License 2.0
1.44k stars 1.06k forks source link

datetime.datetime.utcnow() is deprecated as of Python 3.12 #3201

Closed eduardo-boutiquenumerique closed 2 weeks ago

eduardo-boutiquenumerique commented 2 weeks ago

Describe the bug

The module botocore.auth.py uses the function datetime.datetime.utcnow() which is depreacated and throws the DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).

Expected Behavior

The warning should not be raised

Current Behavior

The DeprecationWarning is being raised

Reproduction Steps

Using last versions botocore and launching python with options -Wa raises the warning

Possible Solution

Replace datetime.datetime.utcnow() with datetime.datetime.now(datetime.UTC) as described in the warning itself

Additional Information/Context

No response

SDK version used

1.34.122

Environment details (OS name and version, etc.)

linux, ubunut

tim-finnigan commented 2 weeks ago

This is a duplicate of https://github.com/boto/boto3/issues/3889. As mentioned there:

The team is aware of this issue and working on addressing the warnings. These deprecations won't cause impact currently beyond the warnings. The required changes are not fully backwards compatible for existing usage. We'll be prioritizing a more robust fix in an upcoming release.

Closing to continue tracking in that issue.

github-actions[bot] commented 2 weeks ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.