diff options
author | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2014-01-11 08:31:19 -0500 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2014-01-11 08:31:19 -0500 |
commit | 53a5e134dc89968abb3984ae687391e7de9c8296 (patch) | |
tree | 13e3fb57dc5e3a1b6aae596dde67bcf8b57a2c1a | |
parent | 9efd9c6d5819203fbae65e7d5cd2824f5337b865 (diff) | |
download | pyopenssl-53a5e134dc89968abb3984ae687391e7de9c8296.tar.gz |
Avoid using `long` if it does not exist.
-rw-r--r-- | OpenSSL/rand.py | 8 |
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: |