Skip to content

DeprecationWarning in Python 3.12 #19

@benoit74

Description

@benoit74

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__)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions