webrecorder / warcio

Streaming WARC/ARC library for fast web archive IO
https://pypi.python.org/pypi/warcio
Apache License 2.0
359 stars 55 forks source link

DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version #163

Open benoit74 opened 4 months ago

benoit74 commented 4 months ago

Since Python 3.12, we have the following DeprecationWarning:

warcio/recordbuilder.py:156: 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).
    return datetime_to_iso_date(datetime.datetime.utcnow(), use_micros=use_micros)

Pretty easy to fix in 3.12, but maybe not that easy in reality since you probably wanna maintain 2.7+ and 3.4+ support. I suggest to not use what the DeprecationWarning suggests but datetime.datetime.now(tzinfo = datetime.tzinfo.UTC) which should be OK (to be checked).

benoit74 commented 1 month ago

I tried to work on this feature by first adding support for Python 3.12 but I fail to get the tests running with it.

First problem is in test_capture_http_proxy.py:

I don't know how to fix this situation

wumpus commented 1 month ago

Tessa @tw4l is working on getting rid of the httpbin version dependency in PR 153 https://github.com/webrecorder/warcio/pull/153 -- and she's setting up Github Actions so we'll have CI again. Once that's done you'll easily be able to finish this one.

benoit74 commented 1 month ago

Oh great, thank you! I'm glad I stopped before investing too much time in this ^^

tw4l commented 1 month ago

I'm struggling with the same HTTPS proxy issue as you document above, but hopefully will work it out soon!

benoit74 commented 1 month ago

Good luck! (I have my own share of struggling, I know what this is ^^)

tw4l commented 1 month ago

Turns out pinning urllib3 to an older version for now resolves it! PR to switch to GitHub Actions CI is now open :) https://github.com/webrecorder/warcio/pull/164