Skip to content

datetime.datetime.utcfromtimestamp is deprecated in Python 3.12 #61

@stefan6419846

Description

@stefan6419846

Using commoncode.filetype.get_last_modified_date on Python 3.12 (for example indirectly through ScanCode Toolkit) will report a deprecation warning (in this case as part of unit/integration tests of my own package which uses ScanCode):

test_file_path (test_retrieval.RunTestCase.test_file_path) ... /opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/site-packages/commoncode/filetype.py:167: 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.utcfromtimestamp(os.path.getmtime(location))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions