gnu: python-pycrypto: Fix build with Python 3.8.
[jackhill/guix/guix.git] / gnu / packages / patches / python-pycrypto-time-clock.patch
1 Drop use of the deprecated time.clock which was removed in Python 3.8.
2
3 Adapted from upstream pull request:
4
5 https://github.com/dlitz/pycrypto/pull/296
6
7 diff --git a/lib/Crypto/Random/_UserFriendlyRNG.py b/lib/Crypto/Random/_UserFriendlyRNG.py
8 --- a/lib/Crypto/Random/_UserFriendlyRNG.py
9 +++ b/lib/Crypto/Random/_UserFriendlyRNG.py
10 @@ -73,8 +73,11 @@ class _EntropyCollector(object):
11 t = time.time()
12 self._time_es.feed(struct.pack("@I", int(2**30 * (t - floor(t)))))
13
14 - # Add the fractional part of time.clock()
15 - t = time.clock()
16 + # Add the fractional part of time.process_time()
17 + try:
18 + t = time.process_time()
19 + except AttributeError:
20 + t = time.clock()
21 self._clock_es.feed(struct.pack("@I", int(2**30 * (t - floor(t)))))
22
23