burnash/gspread — Issue #16: Type Casting problem
Author: ac001
Created: 2012-01-04 23:06:48+00:00
State: open

I'm having to update a cell with an int as value, gpread reports an error during request..
>> TypeError: cannot serialize 11796L (type long)

I am not sure what is the best solution, apart from my side typcasting everyhitn to a string.

option 1
- report an error before the request is made.. ie in update_cell() (if isinstance(v, int) : Throw error

option 2
- Converts int, floats, decimals to unicode automatically...but that leads to another series of problems maybe..

Traceback (most recent call last):
File "./alcontrol.py", line 151, in
sheet.update_cell(curr_row, c, data[ki])
File "/home/geo2lab/geo2pylons/shell/gspread/models.py", line 348, in update_cell
self.client.put_feed(uri, ElementTree.tostring(feed))
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1121, in tostring
ElementTree(element).write(file, encoding, method=method)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 815, in write
serialize(write, self._root, encoding, qnames, namespaces)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 934, in _serialize_xml
_serialize_xml(write, e, encoding, qnames, None)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 927, in _serialize_xml
v = _escape_attrib(v, encoding)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1087, in _escape_attrib
_raise_serialization_error(text)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1047, in _raise_serialization_error
"cannot serialize %r (type %s)" % (text, type(text).__name__)
TypeError: cannot serialize 11796L (type long)