diff --git a/pymongo/mongo_client.py b/pymongo/mongo_client.py index 1c4f2e451..2390f5896 100644 --- a/pymongo/mongo_client.py +++ b/pymongo/mongo_client.py @@ -689,7 +689,7 @@ class MongoClient(common.BaseObject): end = time.time() response = helpers._unpack_response(response)['data'][0] - msg = "command %r failed: %%s" % spec + msg = "command %s failed: %%s" % repr(spec).replace("%", "%%") helpers._check_command_response(response, None, msg) return response, end - start diff --git a/pymongo/mongo_replica_set_client.py b/pymongo/mongo_replica_set_client.py index 40ec23e0a..00a45b018 100644 --- a/pymongo/mongo_replica_set_client.py +++ b/pymongo/mongo_replica_set_client.py @@ -1022,7 +1022,7 @@ class MongoReplicaSetClient(common.BaseObject): end = time.time() response = helpers._unpack_response(response)['data'][0] - msg = "command %r failed: %%s" % spec + msg = "command %s failed: %%s" % repr(spec).replace("%", "%%") helpers._check_command_response(response, None, msg) return response, end - start