PYTHON-940 - Unhelpful and pretty wrong error message.
This commit is contained in:
parent
fc9a053c90
commit
c6abb18b2e
@ -1197,12 +1197,20 @@ class MongoClient(common.BaseObject):
|
||||
"""
|
||||
header = self.__receive_data_on_socket(16, sock_info)
|
||||
length = struct.unpack("<i", header[:4])[0]
|
||||
|
||||
actual_op = struct.unpack("<i", header[12:])[0]
|
||||
assert actual_op == operation, (
|
||||
"wire protocol error: unknown opcode %r" % (actual_op,))
|
||||
|
||||
# No rqst_id for exhaust cursor "getMore".
|
||||
if rqst_id is not None:
|
||||
resp_id = struct.unpack("<i", header[8:12])[0]
|
||||
assert rqst_id == resp_id, "ids don't match %r %r" % (rqst_id,
|
||||
resp_id)
|
||||
assert operation == struct.unpack("<i", header[12:])[0]
|
||||
assert rqst_id == resp_id, (
|
||||
"wire protocol error: got response id %r but expected %r"
|
||||
% (resp_id, rqst_id))
|
||||
|
||||
assert length > 16, ("wire protocol error: message length is shorter"
|
||||
" than standard message header: %r" % (length,))
|
||||
|
||||
return self.__receive_data_on_socket(length - 16, sock_info)
|
||||
|
||||
|
||||
@ -1482,12 +1482,20 @@ class MongoReplicaSetClient(common.BaseObject):
|
||||
"""
|
||||
header = self.__recv_data(16, sock)
|
||||
length = struct.unpack("<i", header[:4])[0]
|
||||
|
||||
actual_op = struct.unpack("<i", header[12:])[0]
|
||||
assert actual_op == operation, (
|
||||
"wire protocol error: unknown opcode %r" % (actual_op,))
|
||||
|
||||
# No rqst_id for exhaust cursor "getMore".
|
||||
if rqst_id is not None:
|
||||
resp_id = struct.unpack("<i", header[8:12])[0]
|
||||
assert rqst_id == resp_id, "ids don't match %r %r" % (rqst_id,
|
||||
resp_id)
|
||||
assert operation == struct.unpack("<i", header[12:])[0]
|
||||
assert rqst_id == resp_id, (
|
||||
"wire protocol error: got response id %r but expected %r"
|
||||
% (resp_id, rqst_id))
|
||||
|
||||
assert length > 16, ("wire protocol error: message length is shorter"
|
||||
" than standard message header: %r" % (length,))
|
||||
|
||||
return self.__recv_data(length - 16, sock)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user