Py3AMF icon indicating copy to clipboard operation
Py3AMF copied to clipboard

DeprecationWarning in Python 3.12

Open benoit74 opened this issue 1 year ago • 0 comments

There is two DeprecationWarning in Python 3.12.

pyamf/util/__init__.py:217: 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).
    datetime.datetime.utcfromtimestamp(-31536000.0)
pyamf/adapters/__init__.py:44
  /home/benoit/Repos/openzim/warc2zim/.hatch/warc2zim/lib/python3.12/site-packages/pyamf/adapters/__init__.py:44: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

First one is probably minor to fix.

Second one is kind of a blocker for Python 3.12, but there is a fallback in the code, so it probably still works in most situations.

The second one can probably easily be fixed with https://docs.python.org/3/library/importlib.resources.html with something like this:

try:
    from importlib import resources
    ....
except:
  try:
    import pkg_resources
    packageDir = pkg_resources.resource_filename('pyamf', 'adapters')
  except:
    packageDir = os.path.dirname(__file__)

benoit74 avatar Mar 01 '24 12:03 benoit74