Skip to content

Commit

Permalink
Remove passing exception as args to super in APIError
Browse files Browse the repository at this point in the history
(cherry picked from commit 0e361b4)
  • Loading branch information
mike-flowers-airbnb authored and alifeee committed Oct 3, 2024
1 parent abb8b10 commit 3319164
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gspread/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class APIError(GSpreadException):
such as when we attempt to retrieve things that don't exist."""

def __init__(self, response: Response):
super().__init__(self._extract_error(response))
super().__init__(response)
self.response: Response = response
self.error: Mapping[str, Any] = response.json()["error"]
self.code: int = self.error["code"]
Expand Down
7 changes: 6 additions & 1 deletion tests/worksheet_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import itertools
import pickle
import random
import re
from inspect import signature
Expand Down Expand Up @@ -1911,4 +1912,8 @@ def test_add_validation(self):
{"spreadsheetId": self.spreadsheet.id, "replies": [{}]},
)

self.assertRaises(APIError, sheet.update, values="X", range_name="A1")
with self.assertRaises(APIError) as ex:
sheet.update(values="X", range_name="A1")

# Ensure that the exception is able to be pickled
pickle.loads(pickle.dumps(ex.exception))

0 comments on commit 3319164

Please sign in to comment.