Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync failure: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128) #127

Open
ph1l opened this issue Nov 21, 2018 · 1 comment · May be fixed by #128

Comments

@ph1l
Copy link

ph1l commented Nov 21, 2018

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;;

@ph1l
Copy link
Author

ph1l commented Nov 21, 2018

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):

ph1l added a commit to ph1l/pycarddav that referenced this issue Nov 21, 2018
@ph1l ph1l linked a pull request Nov 21, 2018 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant