Skip to content

Commit ab84823

Browse files
committed
PYTHON-2438 Fix str representation of BulkWriteError
1 parent 92aed33 commit ab84823

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

pymongo/errors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ def __init__(self, results):
243243
# For pickle support
244244
self.args = (results,)
245245

246+
if sys.version_info[0] != 2:
247+
def __str__(self):
248+
return str(self._message)
249+
246250

247251
class InvalidOperation(PyMongoError):
248252
"""Raised when a client attempts to perform an invalid operation."""

test/test_errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def test_pickle_OperationFailure(self):
9393
def test_pickle_BulkWriteError(self):
9494
exc = BulkWriteError({})
9595
self.assertOperationFailureEqual(exc, pickle.loads(pickle.dumps(exc)))
96+
self.assertIn("batch op errors occurred", str(exc))
9697

9798
def test_pickle_EncryptionError(self):
9899
cause = OperationFailure('error', code=5, details={},

0 commit comments

Comments
 (0)