json-logging-python icon indicating copy to clipboard operation
json-logging-python copied to clipboard

fix: update utcnow for python 3.12 deprecation

Open donbowman opened this issue 1 year ago • 9 comments

In python3.12 we get deprecation errors due to the use of 'naive' timestamps from utcnow. (see https://github.com/python/cpython/issues/103857)

Replace with timezone.utc

See https://github.com/python/cpython/issues/81669

See https://blog.miguelgrinberg.com/post/it-s-time-for-a-change-datetime-utcnow-is-now-deprecated

donbowman avatar Jul 14 '24 20:07 donbowman

I don't quite get why the .replace(tzinfo=None) is there? It would seem that timezone aware date times should be just as well to compute the total seconds. Other than that, this looks like it should solve the issue.

dwt avatar Apr 28 '25 17:04 dwt

@bobbui Is there anything I can do to make this more mergeable? Sadly the last run here is so long ago that the logs are not accessible anymore, so I'm not sure what the problem is.

But this is slowly becoming pressing as we want to update to python 3.14 soon.

dwt avatar Apr 28 '25 17:04 dwt

i can remove the replace(tzinfo=None). The only failure is for py3.7, which IMHO you would remove as it was EOL in 2023.

donbowman avatar Apr 28 '25 17:04 donbowman

i have made a few minor changes to the test environment in this PR:

  • remove python3.7
  • pin sanic
  • update flake8 issues (flake8 is not pinned, neither is pytest)

now all the tests pass at this instance in time.

donbowman avatar Apr 28 '25 17:04 donbowman

@bobbui , please give us some guidance on how we can assist. Do you need another maintainer to help? I think it would be best for the community to keep this alive on the same name/path.

Another option is to hard fork it and merge #107 , #108 , #109 . I'm willing to do that if someone else is willing to be a co-maintainer.

donbowman avatar Apr 29 '25 12:04 donbowman

I'm using it enough so I wouldn't mind to be a co maintainer, but I would mostly provide review and feedback, as I am very much focused on nix and nixos in my open source time right now.

dwt avatar Apr 29 '25 14:04 dwt

Friendly ping to @bobbui Could you please take a look at this issue and help us get this merged?

dwt avatar May 03 '25 18:05 dwt

Another friendly ping to @bobbui - this issue is getting more and more pressing as the package is incompatible with python 3.12, while python 3.14 is getting released any day now.

dwt avatar May 16 '25 13:05 dwt

Friendly Ping to @bobbui - could you please take a look at this - as far as I can see the fix is included.

We would really like to use your library on newer python versions.

dwt avatar May 29 '25 17:05 dwt

Friendly ping at @bobbui Can you give a timeframe when you will be able to look at this?

dwt avatar Jun 30 '25 12:06 dwt

sorry, been really busy with family. change looks good, merged

@dwt if you have time to review #109 it would be great, I really don't have to verify this large change

bobbui avatar Jul 01 '25 20:07 bobbui

@bobbui, I had a Quick Look, and was a bit confused, I'll write something to the developer

dwt avatar Jul 05 '25 18:07 dwt

@bobbui Do you already have a release schedule for this fix? We would like to upgrade our deployments and are running into this problem.

dwt avatar Jul 05 '25 18:07 dwt