Skip to content

ptrace/tools.py:82: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC #89

@jfly

Description

@jfly

This line of code https://github.com/vstinner/python-ptrace/blob/0.9.9/ptrace/tools.py#L81-L82 uses the deprecated datetime.datetime.utcfromtimestamp() function.

I'm not totally sure what the right fix is: it's incorrect to assume that LOCAL_TIMEZONE_OFFSET is a constant, as the system timezone can change during the run of a program. From https://blog.ganssle.io/articles/2022/04/naive-local-datetimes.html:

The local offset may change during the course of the interpreter run.

LOCAL_TIMEZONE_OFFSET is only used by timestampUNIX, which is only used in one place (in getSystemBoot).

I think using datetime.fromtimestamp would be the right solution. I'll send in a PR implementing that.

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