6
6
from weakref import WeakValueDictionary
7
7
from errno import errorcode
8
8
9
- from six import integer_types , int2byte , indexbytes
10
-
11
9
from OpenSSL ._util import (
12
10
UNSPECIFIED as _UNSPECIFIED ,
13
11
exception_from_error_queue as _exception_from_error_queue ,
@@ -381,7 +379,7 @@ def wrapper(ssl, out, outlen, in_, inlen, arg):
381
379
instr = _ffi .buffer (in_ , inlen )[:]
382
380
protolist = []
383
381
while instr :
384
- encoded_len = indexbytes ( instr , 0 )
382
+ encoded_len = instr [ 0 ]
385
383
proto = instr [1 : encoded_len + 1 ]
386
384
protolist .append (proto )
387
385
instr = instr [encoded_len + 1 :]
@@ -551,15 +549,15 @@ def wrapper(ssl, cdata):
551
549
552
550
def _asFileDescriptor (obj ):
553
551
fd = None
554
- if not isinstance (obj , integer_types ):
552
+ if not isinstance (obj , int ):
555
553
meth = getattr (obj , "fileno" , None )
556
554
if meth is not None :
557
555
obj = meth ()
558
556
559
- if isinstance (obj , integer_types ):
557
+ if isinstance (obj , int ):
560
558
fd = obj
561
559
562
- if not isinstance (fd , integer_types ):
560
+ if not isinstance (fd , int ):
563
561
raise TypeError ("argument must be an int, or have a fileno() method." )
564
562
elif fd < 0 :
565
563
raise ValueError (
@@ -653,7 +651,7 @@ class Context(object):
653
651
)
654
652
655
653
def __init__ (self , method ):
656
- if not isinstance (method , integer_types ):
654
+ if not isinstance (method , int ):
657
655
raise TypeError ("method must be an integer" )
658
656
659
657
try :
@@ -897,7 +895,7 @@ def use_certificate_file(self, certfile, filetype=FILETYPE_PEM):
897
895
:return: None
898
896
"""
899
897
certfile = _path_string (certfile )
900
- if not isinstance (filetype , integer_types ):
898
+ if not isinstance (filetype , int ):
901
899
raise TypeError ("filetype must be an integer" )
902
900
903
901
use_result = _lib .SSL_CTX_use_certificate_file (
@@ -958,7 +956,7 @@ def use_privatekey_file(self, keyfile, filetype=_UNSPECIFIED):
958
956
959
957
if filetype is _UNSPECIFIED :
960
958
filetype = FILETYPE_PEM
961
- elif not isinstance (filetype , integer_types ):
959
+ elif not isinstance (filetype , int ):
962
960
raise TypeError ("filetype must be an integer" )
963
961
964
962
use_result = _lib .SSL_CTX_use_PrivateKey_file (
@@ -1035,7 +1033,7 @@ def set_session_cache_mode(self, mode):
1035
1033
1036
1034
.. versionadded:: 0.14
1037
1035
"""
1038
- if not isinstance (mode , integer_types ):
1036
+ if not isinstance (mode , int ):
1039
1037
raise TypeError ("mode must be an integer" )
1040
1038
1041
1039
return _lib .SSL_CTX_set_session_cache_mode (self ._context , mode )
@@ -1070,7 +1068,7 @@ def set_verify(self, mode, callback=None):
1070
1068
1071
1069
See SSL_CTX_set_verify(3SSL) for further details.
1072
1070
"""
1073
- if not isinstance (mode , integer_types ):
1071
+ if not isinstance (mode , int ):
1074
1072
raise TypeError ("mode must be an integer" )
1075
1073
1076
1074
if callback is None :
@@ -1093,7 +1091,7 @@ def set_verify_depth(self, depth):
1093
1091
:param depth: An integer specifying the verify depth
1094
1092
:return: None
1095
1093
"""
1096
- if not isinstance (depth , integer_types ):
1094
+ if not isinstance (depth , int ):
1097
1095
raise TypeError ("depth must be an integer" )
1098
1096
1099
1097
_lib .SSL_CTX_set_verify_depth (self ._context , depth )
@@ -1253,7 +1251,7 @@ def set_timeout(self, timeout):
1253
1251
:param timeout: The timeout in (whole) seconds
1254
1252
:return: The previous session timeout
1255
1253
"""
1256
- if not isinstance (timeout , integer_types ):
1254
+ if not isinstance (timeout , int ):
1257
1255
raise TypeError ("timeout must be an integer" )
1258
1256
1259
1257
return _lib .SSL_CTX_set_timeout (self ._context , timeout )
@@ -1356,7 +1354,7 @@ def set_options(self, options):
1356
1354
:param options: The options to add.
1357
1355
:return: The new option bitmask.
1358
1356
"""
1359
- if not isinstance (options , integer_types ):
1357
+ if not isinstance (options , int ):
1360
1358
raise TypeError ("options must be an integer" )
1361
1359
1362
1360
return _lib .SSL_CTX_set_options (self ._context , options )
@@ -1369,7 +1367,7 @@ def set_mode(self, mode):
1369
1367
:param mode: The mode to add.
1370
1368
:return: The new mode bitmask.
1371
1369
"""
1372
- if not isinstance (mode , integer_types ):
1370
+ if not isinstance (mode , int ):
1373
1371
raise TypeError ("mode must be an integer" )
1374
1372
1375
1373
return _lib .SSL_CTX_set_mode (self ._context , mode )
@@ -1426,7 +1424,7 @@ def set_alpn_protos(self, protos):
1426
1424
# Take the list of protocols and join them together, prefixing them
1427
1425
# with their lengths.
1428
1426
protostr = b"" .join (
1429
- chain .from_iterable ((int2byte ( len (p )), p ) for p in protos )
1427
+ chain .from_iterable ((bytes (( len (p ), )), p ) for p in protos )
1430
1428
)
1431
1429
1432
1430
# Build a C string from the list. We don't need to save this off
@@ -1839,7 +1837,7 @@ def bio_read(self, bufsiz):
1839
1837
if self ._from_ssl is None :
1840
1838
raise TypeError ("Connection sock was not None" )
1841
1839
1842
- if not isinstance (bufsiz , integer_types ):
1840
+ if not isinstance (bufsiz , int ):
1843
1841
raise TypeError ("bufsiz must be an integer" )
1844
1842
1845
1843
buf = _no_zero_allocator ("char[]" , bufsiz )
@@ -2070,7 +2068,7 @@ def set_shutdown(self, state):
2070
2068
:param state: bitvector of SENT_SHUTDOWN, RECEIVED_SHUTDOWN.
2071
2069
:return: None
2072
2070
"""
2073
- if not isinstance (state , integer_types ):
2071
+ if not isinstance (state , int ):
2074
2072
raise TypeError ("state must be an integer" )
2075
2073
2076
2074
_lib .SSL_set_shutdown (self ._ssl , state )
@@ -2454,7 +2452,7 @@ def set_alpn_protos(self, protos):
2454
2452
# Take the list of protocols and join them together, prefixing them
2455
2453
# with their lengths.
2456
2454
protostr = b"" .join (
2457
- chain .from_iterable ((int2byte ( len (p )), p ) for p in protos )
2455
+ chain .from_iterable ((bytes (( len (p ), )), p ) for p in protos )
2458
2456
)
2459
2457
2460
2458
# Build a C string from the list. We don't need to save this off
0 commit comments