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

KeyError when calling update_cell API with unicode sheetname #544

ckclark opened this Issue May 4, 2018 · 2 comments


None yet
2 participants

ckclark commented May 4, 2018

Environment info

Operating System: Ubuntu
Python version: 2.7.13
gspread version: 3.0.0

Steps to reproduce

  1. Create a workbook with sheet name in unicode like 中文
  2. Just execute
sheet = wb.worksheet(u'中文')
sheet.update_cell(1, 1, 'test2')

Stack trace or other output that would be helpful

Traceback (most recent call last):
  File "", line 24, in <module>
  File "", line 21, in main
    sheet.update_cell(1, 1, 'test2')
  File "/tmp/gspread/local/lib/python2.7/dist-packages/gspread/", line 567, in update_cell
    'values': [[value]]
  File "/tmp/gspread/local/lib/python2.7/dist-packages/gspread/", line 114, in values_update
    url = SPREADSHEET_VALUES_URL % (, quote(range, safe=''))
  File "/usr/lib64/python2.7/", line 1299, in quote
    return ''.join(map(quoter, s))
KeyError: u'\u4e2d'

Possible fix

I tweak a little at to
url = SPREADSHEET_VALUES_URL % (, quote(range.encode('UTF-8'), safe=''))
and it will work. Hope this helps.

@burnash burnash added the Bug label Jul 8, 2018


This comment has been minimized.


burnash commented Jul 8, 2018

Thank you for reporting this, I can confirm the bug.


This comment has been minimized.


burnash commented Nov 26, 2018

Thanks again for reporting and for the suggested fix.
It's fixed in #610 and #628
Available in version 3.1.0

@burnash burnash closed this Nov 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment