UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 371: ordinal not in range(128)

Bug #1102730 reported by liuhuanjim013
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python WebDAV Library
New
Undecided
Unassigned

Bug Description

when listing directory containing utf-8 encoded files, i got the following error:

Traceback (most recent call last):
  File "src/webdav/WebdavClient.py", line 877, in <module>
    for resource, properties in webdavConnection.getCollectionContents():
  File "src/webdav/WebdavClient.py", line 711, in getCollectionContents
    result = self.listResources()
  File "src/webdav/WebdavClient.py", line 691, in listResources
    *LiveProperties.NAMES)
  File "/usr/local/lib/python2.6/dist-packages/davlib.py", line 292, in getprops
    return self.propfind(url, body, depth)
  File "/usr/local/lib/python2.6/dist-packages/davlib.py", line 208, in propfind
    return self._request('PROPFIND', url, body, headers)
  File "/usr/local/lib/python2.6/dist-packages/webdav/Connection.py", line 125, in _request
    return self.__evaluateResponse(method, response)
  File "/usr/local/lib/python2.6/dist-packages/webdav/Connection.py", line 158, in __evaluateResponse
    for status in unicode(response.msr).strip().split('\n'):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 371: ordinal not in range(128)

modifying Connection.py in the following way fixes the problem:

158c158
< for status in unicode(response.msr).strip().split('\n'):
---
> for status in unicode(str(response.msr),encoding='utf-8').strip().split('\n'):

thanks!

Revision history for this message
OpenRAVE Development (openrave) wrote :

some people might not be using utf-8. I think it's safer to use

unicode(str(response.msr),encoding=sys.getfilesystemencoding())

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.