pycarddav
pycarddav copied to clipboard
sync failure: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128)
elektron@x200:~/code/deb/pycarddav-0.7.0$ pycardsyncer -v
0.7.0
elektron@x200:~/code/deb/pycarddav-0.7.0$ dpkg -l | grep pycard
ii pycarddav 0.7.0-1 all simple to use CardDAV CLI client
ii python-pycarddav 0.7.0-1 all simple to use CardDAV Python library
elektron@x200:~$ pycardsyncer -c ~/.pycard.conf --debug
DEBUG:root:Using configuration from /home/elektron/.pycard.conf
DEBUG:root:Ignoring default:debug in configuration file
DEBUG:root:Using configuration:
DEBUG:root: accounts:
DEBUG:root: auth: basic
DEBUG:root: name: XXX
DEBUG:root: resource: https://XXX/caldav.php/elektron/addresses/
DEBUG:root: user: elektron
DEBUG:root: verify: False
DEBUG:root: write_support: False
DEBUG:root: debug: True
DEBUG:root: filename: /home/elektron/.pycard.conf
DEBUG:root: sqlite:
DEBUG:root: path: /home/elektron/.pycard_abook.db
DEBUG:root: sync:
DEBUG:root: accounts: set(['XXX'])
DEBUG:root:start syncing account XXX
/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py:849: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
DEBUG:root:made sure version table exists
DEBUG:root:made sure accounts table exists
/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py:849: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
DEBUG:root:made sure XXX table exists
DEBUG:root:getting /caldav.php/elektron/addresses/b77cee22-9ff5-4799-bf16-556a4a8c97f9vcf etag: "9cd9a015b9c4ea12fbf99bfa683c2b86"
/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py:849: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
Traceback (most recent call last):
File "/usr/bin/pycardsyncer", line 55, in <module>
sync(conf)
File "/usr/lib/python2.7/dist-packages/pycarddav/controllers/sync.py", line 57, in sync
my_dbtool.update(vcard, conf.account.name, href=href, etag=etag)
File "/usr/lib/python2.7/dist-packages/pycarddav/backend.py", line 271, in update
stuple = (etag, vcard.name, vcard.fname, vcard_s, status, href, href)
File "/usr/lib/python2.7/dist-packages/pycarddav/model.py", line 200, in name
return unicode(self['N'][0][0]) if self['N'] else ''
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128)
The string it seems to be choking on is Le\xc3\xb3n;Joel;Gil;;
The following seems to allow the sync to complete, but I'm not sure if it's the fix:
elektron@x200:~/code$ diff -Naur pycarddav/pycarddav/model.py /usr/lib/python2.7/dist-packages/pycarddav/model.py
--- pycarddav/pycarddav/model.py 2018-11-21 11:02:56.765793646 -0800
+++ /usr/lib/python2.7/dist-packages/pycarddav/model.py 2018-11-21 12:41:04.327831364 -0800
@@ -197,7 +197,7 @@
@property
def name(self):
- return unicode(self['N'][0][0]) if self['N'] else ''
+ return unicode(self['N'][0][0].decode('utf8')) if self['N'] else ''
@name.setter
def name(self, value):
@@ -207,7 +207,7 @@
@property
def fname(self):
- return unicode(self['FN'][0][0]) if self['FN'] else ''
+ return unicode(self['FN'][0][0].decode('utf8')) if self['FN'] else ''
@fname.setter
def fname(self, value):