Skip to content
Snippets Groups Projects
Commit f2bbbf74 authored by Damian Johnson's avatar Damian Johnson
Browse files

Python3 stacktrace when dates are on a year boundary

Oops, python3 compatibility issue...

  https://trac.torproject.org/projects/tor/ticket/24820

  >>> import time
  >>> time.mktime(list(time.strptime('2017', '%Y')))
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  TypeError: Tuple or struct_time argument required

As above, this needs to be swapped to a tuple. I'm a tad tempted to simply
subtract 31536000 (the number of seconds in a year) from the unix timestamp
instead, but on reflection there's leap years, leap seconds, and god knows
what else so... meh.
parent 4de3324f
No related branches found
No related tags found
No related merge requests found
......@@ -494,7 +494,7 @@ def read_tor_log(path, read_limit = None):
if timestamp > time.time():
# log entry is from before a year boundary
timestamp_comp[0] -= 1
timestamp = int(time.mktime(timestamp_comp))
timestamp = int(time.mktime(tuple(timestamp_comp)))
except ValueError:
raise ValueError("Log located at %s has a timestamp we don't recognize: %s" % (path, ' '.join(line_comp[:3])))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment