Fix things again, this time for python3
This commit is contained in:
parent
753cb3580e
commit
768136e493
@ -11,7 +11,8 @@
|
|||||||
|
|
||||||
|
|
||||||
from sleekxmpp.util.misc_ops import bytes, unicode, hashes, hash, \
|
from sleekxmpp.util.misc_ops import bytes, unicode, hashes, hash, \
|
||||||
num_to_bytes, bytes_to_num, quote, XOR
|
num_to_bytes, bytes_to_num, quote, \
|
||||||
|
XOR, safedict
|
||||||
|
|
||||||
|
|
||||||
# =====================================================================
|
# =====================================================================
|
||||||
|
@ -129,6 +129,7 @@ def hashes():
|
|||||||
hashes = ['SHA-' + h[3:] for h in dir(hashlib) if h.startswith('sha')]
|
hashes = ['SHA-' + h[3:] for h in dir(hashlib) if h.startswith('sha')]
|
||||||
return t + hashes
|
return t + hashes
|
||||||
|
|
||||||
|
|
||||||
def setdefaultencoding(encoding):
|
def setdefaultencoding(encoding):
|
||||||
"""
|
"""
|
||||||
Set the current default string encoding used by the Unicode implementation.
|
Set the current default string encoding used by the Unicode implementation.
|
||||||
@ -152,3 +153,13 @@ def setdefaultencoding(encoding):
|
|||||||
raise RuntimeError("Could not find setdefaultencoding")
|
raise RuntimeError("Could not find setdefaultencoding")
|
||||||
sys.setdefaultencoding = func
|
sys.setdefaultencoding = func
|
||||||
return func(encoding)
|
return func(encoding)
|
||||||
|
|
||||||
|
|
||||||
|
def safedict(data):
|
||||||
|
if sys.version_info < (2, 7):
|
||||||
|
safe = {}
|
||||||
|
for key in data:
|
||||||
|
safe[key.encode('utf8')] = data[key]
|
||||||
|
return safe
|
||||||
|
else:
|
||||||
|
return data
|
||||||
|
@ -31,7 +31,7 @@ import errno
|
|||||||
from xml.parsers.expat import ExpatError
|
from xml.parsers.expat import ExpatError
|
||||||
|
|
||||||
import sleekxmpp
|
import sleekxmpp
|
||||||
from sleekxmpp.util import Queue, QueueEmpty
|
from sleekxmpp.util import Queue, QueueEmpty, safedict
|
||||||
from sleekxmpp.thirdparty.statemachine import StateMachine
|
from sleekxmpp.thirdparty.statemachine import StateMachine
|
||||||
from sleekxmpp.xmlstream import Scheduler, tostring, cert
|
from sleekxmpp.xmlstream import Scheduler, tostring, cert
|
||||||
from sleekxmpp.xmlstream.stanzabase import StanzaBase, ET, ElementBase
|
from sleekxmpp.xmlstream.stanzabase import StanzaBase, ET, ElementBase
|
||||||
@ -518,13 +518,13 @@ class XMLStream(object):
|
|||||||
else:
|
else:
|
||||||
cert_policy = ssl.CERT_REQUIRED
|
cert_policy = ssl.CERT_REQUIRED
|
||||||
|
|
||||||
ssl_args = {
|
ssl_args = safedict({
|
||||||
b'certfile': self.certfile,
|
'certfile': self.certfile,
|
||||||
b'keyfile': self.keyfile,
|
'keyfile': self.keyfile,
|
||||||
b'ca_certs': self.ca_certs,
|
'ca_certs': self.ca_certs,
|
||||||
b'cert_reqs': cert_policy,
|
'cert_reqs': cert_policy,
|
||||||
b'do_handshake_on_connect': False,
|
'do_handshake_on_connect': False
|
||||||
}
|
})
|
||||||
|
|
||||||
if sys.version_info >= (2, 7):
|
if sys.version_info >= (2, 7):
|
||||||
ssl_args['ciphers'] = self.ciphers
|
ssl_args['ciphers'] = self.ciphers
|
||||||
@ -842,13 +842,13 @@ class XMLStream(object):
|
|||||||
else:
|
else:
|
||||||
cert_policy = ssl.CERT_REQUIRED
|
cert_policy = ssl.CERT_REQUIRED
|
||||||
|
|
||||||
ssl_args = {
|
ssl_args = safedict({
|
||||||
b'certfile': self.certfile,
|
'certfile': self.certfile,
|
||||||
b'keyfile': self.keyfile,
|
'keyfile': self.keyfile,
|
||||||
b'ca_certs': self.ca_certs,
|
'ca_certs': self.ca_certs,
|
||||||
b'cert_reqs': cert_policy,
|
'cert_reqs': cert_policy,
|
||||||
b'do_handshake_on_connect': False,
|
'do_handshake_on_connect': False
|
||||||
}
|
})
|
||||||
|
|
||||||
if sys.version_info >= (2, 7):
|
if sys.version_info >= (2, 7):
|
||||||
ssl_args['ciphers'] = self.ciphers
|
ssl_args['ciphers'] = self.ciphers
|
||||||
|
Loading…
Reference in New Issue
Block a user