cpbotha / nvpy

Simplenote syncing note-taking application, inspired by Notational Velocity and ResophNotes, but uglier and cross-platformerer.
Other
849 stars 114 forks source link

nvpy v2.0.0 doesn't work offline #191

Closed yuuki0xff closed 4 years ago

yuuki0xff commented 4 years ago
2019-10-02 04:58:52,738 - DEBUG - nvpy logging initialized
2019-10-02 04:58:52,738 - DEBUG - config read from ['/home/yuuki/.nvpy.cfg']
2019-10-02 04:58:53,453 - DEBUG - Starting full sync.
2019-10-02 04:58:53,464 - DEBUG - Retrieving full note list from server, could take a while.
2019-10-02 04:58:53,468 - ERROR - Traceback (most recent call last):
  File "/home/yuuki/.local/lib/python3.7/site-packages/nvpy/notes_db.py", line 793, in sync_full_unthreaded
    nl = self.simplenote.get_note_list(data=False)
  File "/home/yuuki/.local/lib/python3.7/site-packages/simplenote/simplenote.py", line 273, in get_note_list
    response = urllib2.urlopen(request)
  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.7/urllib/request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1285, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python3.7/http/client.py", line 1221, in putheader
    if _is_illegal_header_value(values[i]):
TypeError: expected string or bytes-like object
yuuki0xff commented 4 years ago

Caused by a bug in the simplenote library.

>>> import simplenote
>>> sn = simplenote.Simplenote('foo', 'bar')
>>> sn.get_token() is None
True

>>> import urllib.request
>>> req = urllib.request.Request('https://github.com')
>>> req.add_header('foo', None)
>>> urllib.request.urlopen(req)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.7/urllib/request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1285, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python3.7/http/client.py", line 1221, in putheader
    if _is_illegal_header_value(values[i]):
TypeError: expected string or bytes-like object
yuuki0xff commented 4 years ago

Added workaround code in a20dc63.