[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [nyx/master] Python3 stacktrace when dates are on a year boundary



commit f2bbbf74e144a635738e122631cf02c855c1246e
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Apr 2 11:35:08 2018 -0700

    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.
---
 nyx/log.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nyx/log.py b/nyx/log.py
index 08a4878..37db680 100644
--- a/nyx/log.py
+++ b/nyx/log.py
@@ -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])))
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits