From 9733c5e7faf9aee874c1176381abcda98deb48f9 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Tue, 1 Sep 2020 18:42:56 -0400 Subject: Work around PyCrypto being EOL and therefore not tracking Python 3.8 This is a short term kludge to let the old unit test code continue to work under Python 3.8. Medium term, we should replace all use of PyCrypto with PyCryptodome (API-compatible successor package). Long term we might want a newer API, but that can wait. --- unit-tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/unit-tests.py b/unit-tests.py index c2f7171..526379c 100644 --- a/unit-tests.py +++ b/unit-tests.py @@ -41,6 +41,7 @@ import unittest import datetime import binascii import logging +import time import sys from struct import pack, unpack @@ -76,6 +77,20 @@ except ImportError: ecdsa_loaded = False +# PyCrypto has been deprecated, at some point we should move on to +# pycryptodome, cryptography.io, or some other modern thing. For the +# moment, an awful kludge to let PyCrypto hobble a little further with +# Python 3.8. +# +# Given that PyCrypto is using this as input to its random number +# generator, you should not use any keys generated by PyCrypto with +# this hack in place for any serious purpose: they're fine as +# throwaway test keys, but not for securing any data you care about. + +if pycrypto_loaded and not hasattr(time, "clock") and hasattr(time, "process_time"): + time.clock = time.process_time + + logger = logging.getLogger("unit-tests") -- cgit v1.2.3