Python client-side WebDAV Library

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

Reported by liuhuanjim013 on 2013-01-22
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python WebDAV Library
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!

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  Edit
Everyone can see this information.

Other bug subscribers