summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Pevec <apevec@redhat.com>2019-07-11 13:31:53 +0200
committerAlan Pevec <apevec@redhat.com>2019-07-11 13:31:53 +0200
commitcae7405b781ed3aebd7cd145889c683cc1b35bf8 (patch)
tree7fa1785b97975b10daaa8ea1c2002cc6a0174541
parent98217ac46e46d10d0968764fda2167edc595c08c (diff)
downloadpasslib-cae7405b781ed3aebd7cd145889c683cc1b35bf8.tar.gz
Remove time.clock(), deprecated in 3.8
The function time.clock(), used in passlib/utils/__init__.py has been removed. It was deprecated since Python 3.3. More info: https://docs.python.org/3.8/whatsnew/3.8.html#api-and-feature-removals To make the code both Python 2 and 3 compatible, use timeit.default_timer
-rw-r--r--passlib/utils/__init__.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py
index fcc9686..d3f9869 100644
--- a/passlib/utils/__init__.py
+++ b/passlib/utils/__init__.py
@@ -30,6 +30,7 @@ else:
import time
if stringprep:
import unicodedata
+import timeit
import types
from warnings import warn
# site
@@ -839,14 +840,7 @@ def test_crypt(secret, hash):
assert secret and hash
return safe_crypt(secret, hash) == hash
-# pick best timer function to expose as "tick" - lifted from timeit module.
-if sys.platform == "win32":
- # On Windows, the best timer is time.clock()
- from time import clock as timer
-else:
- # On most other platforms the best timer is time.time()
- from time import time as timer
-
+timer = timeit.default_timer
# legacy alias, will be removed in passlib 2.0
tick = timer
@@ -903,7 +897,7 @@ def genseed(value=None):
# the current time, to whatever precision os uses
time.time(),
- time.clock(),
+ tick(),
# if urandom available, might as well mix some bytes in.
os.urandom(32).decode("latin-1") if has_urandom else 0,