geier / pycarddav

DEPRECATED - use vdirsyncer & khard -- easy to use CLI CardDAV client
http://lostpackets.de/pycarddav
MIT License
98 stars 35 forks source link

New vobject breaks pycarddav #119

Open DamienCassou opened 8 years ago

DamienCassou commented 8 years ago

Pycarddav depends on vobject. The vobject project from http://vobject.skyhouseconsulting.com/ is dead. The version from @adieu seems to be ok as new dependency for pycarddav. The sligthly more recent version from @tBaxter breaks pycarddav:

$ pc_query 
Traceback (most recent call last):
  File "/nix/store/l126iyrv7f2f5jh13d9nk5jalvijm38j-python2.7-pycarddav-0.7.0/bin/.pc_query-wrapped", line 139, in <module>
    query(conf)
  File "/nix/store/l126iyrv7f2f5jh13d9nk5jalvijm38j-python2.7-pycarddav-0.7.0/lib/python2.7/site-packages/pycarddav/controllers/query.py", line 60, in query
    action(my_dbtool, search_string, conf)
  File "/nix/store/l126iyrv7f2f5jh13d9nk5jalvijm38j-python2.7-pycarddav-0.7.0/lib/python2.7/site-packages/pycarddav/controllers/query.py", line 125, in search
    lines = vcard.pretty_min
  File "/nix/store/l126iyrv7f2f5jh13d9nk5jalvijm38j-python2.7-pycarddav-0.7.0/lib/python2.7/site-packages/pycarddav/model.py", line 257, in pretty_min
    return self._pretty_base(['TEL', 'EMAIL'])
  File "/nix/store/l126iyrv7f2f5jh13d9nk5jalvijm38j-python2.7-pycarddav-0.7.0/lib/python2.7/site-packages/pycarddav/model.py", line 262, in _pretty_base
    collector.append('\n' + BTEXT + 'Name: ' + self.fname + NTEXT)
  File "/nix/store/l126iyrv7f2f5jh13d9nk5jalvijm38j-python2.7-pycarddav-0.7.0/lib/python2.7/site-packages/pycarddav/model.py", line 210, in fname
    return unicode(self['FN'][0][0]) if self['FN'] else ''
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128)
DamienCassou commented 8 years ago

This bug is similar to https://github.com/scheibler/khard/issues/30

dbeniamine commented 7 years ago

I have the same issue and also with the command pycardsyncer, after a quick search (see here) I found that adding the following two lines after the import sys in both /usr/local/bin/pc_query and /usr/local/bin/pycardsyncer seems to resolve the problem:

reload(sys)
sys.setdefaultencoding('utf-8')

I guess that it is a dirty hotfix but for me it seems to fix the bug and I can finally sync and access my contacts again.