Skip to content

Commit bbb701f

Browse files
pcorpetShaneHarvey
authored andcommitted
PYTHON-2438 Fix str representation of BulkWriteError (#522)
(cherry picked from commit 86d5811)
1 parent 5662570 commit bbb701f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pymongo/errors.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,9 @@ class BulkWriteError(OperationFailure):
240240
def __init__(self, results):
241241
super(BulkWriteError, self).__init__(
242242
"batch op errors occurred", 65, results)
243-
# For pickle support
244-
self.args = (results,)
243+
244+
def __reduce__(self):
245+
return self.__class__, (self.details,)
245246

246247

247248
class InvalidOperation(PyMongoError):

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)