#9730 closed defect (fixed)
"AttributeError: 'list' object has no attribute 'decode'"
Reported by: | Felix | Owned by: | François Granade |
---|---|---|---|
Priority: | normal | Component: | TicketImportPlugin |
Severity: | normal | Keywords: | |
Cc: | Jun Omae | Trac Release: | 0.12 |
Description
Hi, trying to import a csv or something else errors at:
2012-01-26 10:16:28,645 Trac[main] ERROR: Internal Server Error: Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/Trac-0.12.2-py2.6.egg/trac/web/main.py", line 511, in _dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.6/site-packages/Trac-0.12.2-py2.6.egg/trac/web/main.py", line 237, in dispatch resp = chosen_handler.process_request(req) File "/usr/lib/python2.6/site-packages/TicketImport-0.8-py2.6.egg/talm_importer/importer.py", line 77, in process_request encoding=req.session['importer.encoding']) File "/usr/lib/python2.6/site-packages/TicketImport-0.8-py2.6.egg/talm_importer/importer.py", line 121, in _do_preview return self._process(filereader, get_reporter_id(req), PreviewProcessor(self.env, req)) File "/usr/lib/python2.6/site-packages/TicketImport-0.8-py2.6.egg/talm_importer/importer.py", line 317, in _process for row in rows: File "/usr/lib/python2.6/site-packages/TicketImport-0.8-py2.6.egg/talm_importer/readers.py", line 60, in next return dict((_to_unicode(key), _to_unicode(val)) for key, val in d.iteritems()) File "/usr/lib/python2.6/site-packages/TicketImport-0.8-py2.6.egg/talm_importer/readers.py", line 60, in <genexpr> return dict((_to_unicode(key), _to_unicode(val)) for key, val in d.iteritems()) File "/usr/lib/python2.6/site-packages/TicketImport-0.8-py2.6.egg/talm_importer/readers.py", line 45, in _to_unicode return val.decode('utf-8') AttributeError: 'list' object has no attribute 'decode'
But I also possibly found the solution: Change in readers.py (of ver. 0.8.2):
42 def _to_unicode(val): 43 if val is None or isinstance(val, unicode): 44 return val 45 return val.decode('utf-8')
to:
42 def _to_unicode(val): 43 if val is None or isinstance(val, unicode): 44 return val[0] 45 return val[0].decode('utf-8')
Attachments (2)
Change History (8)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
sorry, I think this case can be closed as wontfix: The CSV we used had errors: first line was defining the fields with 5 separations but some lines beneath the "description" part contained also some ";" (semicolon) that were interpreted as separators and this error appeared. I attached the csvs. Maybe there can be implemented an improvement not to throw that Exception but a Warning that the csv is nod valid - so you know to look into the csv.
btw: with my change you don't get this warning but also the valid one does not work :/
Sorry for that.
comment:3 Changed 13 years ago by
comment:4 Changed 13 years ago by
Cc: | Jun Omae added; anonymous removed |
---|
comment:6 Changed 7 years ago by
42 def _to_unicode(val): 43 if val is None or isinstance(val, unicode): 44 return val[0] 45 return val[0].decode('utf-8')
42 def _to_unicode(val): 43 if val is None or isinstance(val, unicode): 44 return val[0] 45 return val[0][0].decode('utf-8')
have other question,to link https://pdf-lib.org/Home/Details/1098
Hello snoopotic - could you attach a .csv file that exposes the problem ? I'd love to take your patch but would like to add a testcase too..