gspread icon indicating copy to clipboard operation
gspread copied to clipboard

[bug] Incorrect RequestError handling

Open vicproon opened this issue 9 years ago • 6 comments

Problem

When i try to perform some illegal update cell action (e.g. reformat table with freezed rows) the handling of gspread.exceptions.RequestError is done incorrectly: it is trying to access ex[0] rather thatn ex.args[0], what results in raising of TypeError rather than UpdateCellError

How to fix

replace ex[0] to ex.args[0] in all similar cases.

Environment info

Operating System: Windows 7, 64bit Python version: 3.6.0 64bit gspread version: 0.6.2

Steps to reproduce

  1. create a worksheet with freezed rows (view->freeze)
  2. ws.resize(rows=1, cols=1)

Stack trace or other output that would be helpful

c:\python36\lib\site-packages\gspread\client.py in put_feed(self, url, data)
    219             r = self.session.put(url, data, headers=headers)
    220         except RequestError as ex:
--> 221             if ex[0] == 403:
    222                 raise UpdateCellError(ex[1])
    223             else:

TypeError: 'RequestError' object does not support indexing

In [2]:

vicproon avatar Feb 28 '17 14:02 vicproon

same problem here

rustanacexd avatar Aug 14 '17 14:08 rustanacexd

@vicproon Was it resolved?

kadnan avatar Aug 20 '17 08:08 kadnan

Had the same bug today; code still attempts to access ex[0].

Samwalton9 avatar Nov 14 '17 12:11 Samwalton9

Same issue. Seems to be resolved in gspread-2.1.1.

TheMatt2 avatar Apr 07 '18 17:04 TheMatt2

@TheGreatKetchup thanks for the feedback. @vicproon can you check if the upgrade to the latest gspread version solves the issue for you?

burnash avatar Apr 07 '18 19:04 burnash

I'm closing this issue due to inactivity. Feel free to reopen it if you have an update.

burnash avatar Apr 13 '18 09:04 burnash