Skip to content

Error: module 'time' has no attribute 'clock' #2

@thomasgoodfellow

Description

@thomasgoodfellow

Fails on Python 3.10 (and presumably 3.8 onwards)

Traceback (most recent call last):
  File "/space/thomasg/gh_reflog/coredsl2tablegen/./git-github-reflog", line 496, in <module>
    action_time = time.clock()
AttributeError: module 'time' has no attribute 'clock'

due to time.clock() being removed: (3.8 release notes have "The function time.clock() has been removed, after having been deprecated since Python 3.3: use time.perf_counter() or time.process_time() instead, depending on your requirements, to have well-defined behavior. (Contributed by Matthias Bussonnier in bpo-36895.")

I tried an ignorant monkey patch taken from stackoverflow of restoring it as an alias:

import time
time.clock = time.time

which seemingly worked ok (error vanquished, log output agreed with my expectations), but I didn't look at or think about how clock() was being used, so don't have a merge request.

Thanks for this useful tool!

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