Make startup assertions work in py2
This commit is contained in:
parent
4770807c04
commit
16c4e7dd2a
1 changed files with 6 additions and 1 deletions
|
|
@ -29,6 +29,7 @@ import select
|
||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
import struct
|
import struct
|
||||||
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import textwrap
|
import textwrap
|
||||||
import threading
|
import threading
|
||||||
|
|
@ -40,6 +41,7 @@ from collections import namedtuple
|
||||||
VERSION_SSL = b'\x04\xd2\x16\x2f'
|
VERSION_SSL = b'\x04\xd2\x16\x2f'
|
||||||
VERSION_3 = b'\x00\x03\x00\x00'
|
VERSION_3 = b'\x00\x03\x00\x00'
|
||||||
SSL_STARTUP_RESPONSE = b'S'
|
SSL_STARTUP_RESPONSE = b'S'
|
||||||
|
PY2 = sys.version_info < (3, 0, 0)
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
@ -413,7 +415,10 @@ def parse_options_from_startup_packet(data):
|
||||||
raw_key_value_pairs = data[8:]
|
raw_key_value_pairs = data[8:]
|
||||||
assert raw_key_value_pairs[-1] == 0
|
assert raw_key_value_pairs[-1] == 0
|
||||||
raw_key_value_pairs = raw_key_value_pairs[0:-1]
|
raw_key_value_pairs = raw_key_value_pairs[0:-1]
|
||||||
assert raw_key_value_pairs.count(0) % 2 == 0
|
if PY2:
|
||||||
|
assert raw_key_value_pairs.count('\0') % 2 == 0
|
||||||
|
else:
|
||||||
|
assert raw_key_value_pairs.count(0) % 2 == 0
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
key_value_pairs = data[8:].split(b'\x00')
|
key_value_pairs = data[8:].split(b'\x00')
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue