summaryrefslogtreecommitdiff
path: root/OpenSSL/SSL.py
diff options
context:
space:
mode:
authorJean-Paul Calderone <exarkun@twistedmatrix.com>2014-02-02 18:13:31 -0500
committerJean-Paul Calderone <exarkun@twistedmatrix.com>2014-02-02 18:13:31 -0500
commitbef4f4c324fdb1b4040901993ffd590603a59690 (patch)
tree9097f5f4fdbc84c3211b959ab9829c662f304aa5 /OpenSSL/SSL.py
parent2a78d98ce71b46c0e0013b745d4e937aa7fafa41 (diff)
downloadpyopenssl-bef4f4c324fdb1b4040901993ffd590603a59690.tar.gz
Add some missing test coverage for handling values of type `long` and fix the implementation to accept either `int` or `long` on Python 2 (more closely matching the API implemented by the old C code).
Diffstat (limited to 'OpenSSL/SSL.py')
-rw-r--r--OpenSSL/SSL.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py
index f21ad9d..9c375b0 100644
--- a/OpenSSL/SSL.py
+++ b/OpenSSL/SSL.py
@@ -508,7 +508,7 @@ class Context(object):
bitwise or)
:returns: The previously set caching mode.
"""
- if not isinstance(mode, int):
+ if not isinstance(mode, integer_types):
raise TypeError("mode must be an integer")
return _lib.SSL_CTX_set_session_cache_mode(self._context, mode)
@@ -532,7 +532,7 @@ class Context(object):
See SSL_CTX_set_verify(3SSL) for further details.
"""
- if not isinstance(mode, int):
+ if not isinstance(mode, integer_types):
raise TypeError("mode must be an integer")
if not callable(callback):
@@ -550,7 +550,7 @@ class Context(object):
:param depth: An integer specifying the verify depth
:return: None
"""
- if not isinstance(depth, int):
+ if not isinstance(depth, integer_types):
raise TypeError("depth must be an integer")
_lib.SSL_CTX_set_verify_depth(self._context, depth)
@@ -675,7 +675,7 @@ class Context(object):
:param timeout: The timeout in seconds
:return: The previous session timeout
"""
- if not isinstance(timeout, int):
+ if not isinstance(timeout, integer_types):
raise TypeError("timeout must be an integer")
return _lib.SSL_CTX_set_timeout(self._context, timeout)
@@ -747,7 +747,7 @@ class Context(object):
:param options: The options to add.
:return: The new option bitmask.
"""
- if not isinstance(options, int):
+ if not isinstance(options, integer_types):
raise TypeError("options must be an integer")
return _lib.SSL_CTX_set_options(self._context, options)
@@ -760,7 +760,7 @@ class Context(object):
:param mode: The mode to add.
:return: The new mode bitmask.
"""
- if not isinstance(mode, int):
+ if not isinstance(mode, integer_types):
raise TypeError("mode must be an integer")
return _lib.SSL_CTX_set_mode(self._context, mode)
@@ -945,8 +945,6 @@ class Connection(object):
buf = buf.tobytes()
if not isinstance(buf, bytes):
raise TypeError("data must be a byte string")
- if not isinstance(flags, int):
- raise TypeError("flags must be an integer")
result = _lib.SSL_write(self._ssl, buf, len(buf))
self._raise_ssl_error(self._ssl, result)
@@ -969,8 +967,6 @@ class Connection(object):
buf = buf.tobytes()
if not isinstance(buf, bytes):
raise TypeError("buf must be a byte string")
- if not isinstance(flags, int):
- raise TypeError("flags must be an integer")
left_to_send = len(buf)
total_sent = 0
@@ -1031,7 +1027,7 @@ class Connection(object):
if self._from_ssl is None:
raise TypeError("Connection sock was not None")
- if not isinstance(bufsiz, int):
+ if not isinstance(bufsiz, integer_types):
raise TypeError("bufsiz must be an integer")
buf = _ffi.new("char[]", bufsiz)