boto3 icon indicating copy to clipboard operation
boto3 copied to clipboard

Boto3 UTC DeprecationWarnings

Open BookWorm0 opened this issue 1 year ago • 13 comments

Describe the bug

Running the attached script under Python 3.12 with Python flag -Wa produces DepricationWarnings. bug.txt

Expected Behavior

No warnings should be issued.

Current Behavior

For "import boto3", the warning is: dateutil\tz\tz.py:37: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC). EPOCH = datetime.datetime.utcfromtimestamp(0)

For s3client.list_objects, the warning is: botocore\auth.py:419: 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). datetime_now = datetime.datetime.utcnow()

Reproduction Steps

Rename the script from bug.txt to bug.py.

Run the script as follows from CMD.EXE: py -Wa bug.py BUCKETNAME

where BUCKETNAME identifies an S3 bucket to which you are authorized to access.

Possible Solution

Boto source code should be modified as suggested in the warnings.

Additional Information/Context

No response

SDK version used

boto3-1.28.61 botocore-1.31.61

Environment details (OS name and version, etc.)

Windows 10 Pro Version 10.0.19045 Build 19045; Python 3.12.0

BookWorm0 avatar Oct 06 '23 01:10 BookWorm0

Hi @BookWorm0 thanks for reaching out. 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.

tim-finnigan avatar Oct 06 '23 19:10 tim-finnigan

@tim-finnigan Thank you very much!

kfrydel avatar Oct 16 '23 16:10 kfrydel

Any update on this as the warnings break my CI/CD flow unless I turn off error::DeprecationWarning which I really don't want to

StevenMapes avatar Dec 14 '23 10:12 StevenMapes

Add pytest decorator to affected tests, if you use pytest @pytest.mark.filterwarnings("ignore:datetime.datetime.utcnow")

alex-morgun avatar Jul 04 '24 04:07 alex-morgun

Hello @tim-finnigan, any updates on this?

nathanagez avatar Jul 15 '24 17:07 nathanagez

Any updates on this?

antoniogamizbadger avatar Jul 23 '24 08:07 antoniogamizbadger

Do you happen to have any updates on this?

aronyanez10 avatar Aug 08 '24 23:08 aronyanez10