summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Paul Calderone <exarkun@twistedmatrix.com>2014-01-11 08:31:19 -0500
committerJean-Paul Calderone <exarkun@twistedmatrix.com>2014-01-11 08:31:19 -0500
commit53a5e134dc89968abb3984ae687391e7de9c8296 (patch)
tree13e3fb57dc5e3a1b6aae596dde67bcf8b57a2c1a
parent9efd9c6d5819203fbae65e7d5cd2824f5337b865 (diff)
downloadpyopenssl-53a5e134dc89968abb3984ae687391e7de9c8296.tar.gz
Avoid using `long` if it does not exist.
-rw-r--r--OpenSSL/rand.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/OpenSSL/rand.py b/OpenSSL/rand.py
index cddfd2d..9eed0d4 100644
--- a/OpenSSL/rand.py
+++ b/OpenSSL/rand.py
@@ -23,6 +23,12 @@ _unspecified = object()
_builtin_bytes = bytes
+try:
+ _integer_types = (int, long)
+except NameError:
+ _integer_types = (int,)
+
+
def bytes(num_bytes):
"""
Get some random bytes as a string.
@@ -30,7 +36,7 @@ def bytes(num_bytes):
:param num_bytes: The number of bytes to fetch
:return: A string of random bytes
"""
- if not isinstance(num_bytes, (int, long)):
+ if not isinstance(num_bytes, _integer_types):
raise TypeError("num_bytes must be an integer")
if num_bytes < 0: