Skip to content

PYTHON-2438 Fix str representation of BulkWriteError #522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pymongo/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,9 @@ class BulkWriteError(OperationFailure):
def __init__(self, results):
super(BulkWriteError, self).__init__(
"batch op errors occurred", 65, results)
# For pickle support
self.args = (results,)

def __reduce__(self):
return self.__class__, (self.details,)


class InvalidOperation(PyMongoError):
Expand Down
1 change: 1 addition & 0 deletions test/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def test_pickle_OperationFailure(self):
def test_pickle_BulkWriteError(self):
exc = BulkWriteError({})
self.assertOperationFailureEqual(exc, pickle.loads(pickle.dumps(exc)))
self.assertIn("batch op errors occurred", str(exc))

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