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

Provide better error handling/notification around improper TLS setup #23

Open
vsantana opened this issue Oct 5, 2018 · 13 comments
Open
Labels
easier up for grabs Maintainer has no plans to work themselves. Feel free to tackle.

Comments

@vsantana
Copy link

vsantana commented Oct 5, 2018

This issue is for adding better error handling around the absence of CA certs, etc locally.

I.e. reading through the below you'll see it's not immediately obvious why simplenote.py failed.

Ideally simplenote.py should detect this as an issue and report it out as an error.

Original issue below


There's any support to python3?
sn.get_note_list(tags=[]) gets a TypeError: expected string or bytes-like object on python3

@atomicules
Copy link
Collaborator

It gets tested/built on Python 2 and 3 and so should work.

What version are you running? I.e. 3.X?

What OS?

@vsantana
Copy link
Author

vsantana commented Oct 9, 2018

Hi @atomicules !
My enviroment:
Python 3.6.4 on MacOs High Sierra
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

My code:

-> import simplenote
-> sn = simplenote.Simplenote('my email', 'my password')
-> sn.get_note_list(tags=[])
<- Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/simplenote/simplenote.py", line 252, in get_note_list
response = urllib2.urlopen(request)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1280, in _send_request
self.putheader(hdr, value)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1216, in putheader
if _is_illegal_header_value(values[i]):
TypeError: expected string or bytes-like object

@atomicules
Copy link
Collaborator

It doesn't seem to be a Python3 error.

I do have access to MacOS (10.14), but I have Pkgsrc on there instead of Homebrew:

Python 3.7.0 (default, Oct  1 2018, 20:41:05) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import simplenote
>>> sn = simplenote.Simplenote("email", "password")
>>> notes = sn.get_note_list()

works fine.

This:

return opener.open(url, data, timeout)
[...]
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open

Looks like an issue accessing the API url. On that note, are you using the recent 2.X simplenote.py release?

Simplenote closed off the old API:

Legacy Simplenote API

Some older applications may still be using the legacy Simplenote API at https://simple-note.appspot.com. Note that this API has been deprecated and will no longer function after October 1, 2018.

@vsantana
Copy link
Author

I'm using a recent release:

▶ pip3 show simplenote
Name: simplenote
Version: 2.0.2
Summary: Python library for the simplenote.com API
Home-page: https://github.com/mrtazz/simplenote.py
Author: Daniel Schauenberg
Author-email: [email protected]
License: MIT
Location: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requires:
Required-by:

How can I check wich API url?

In python2 works fine.

▶ pip2 show simplenote
Name: simplenote
Version: 2.0.2
Summary: Python library for the simplenote.com API
Home-page: https://github.com/mrtazz/simplenote.py
Author: Daniel Schauenberg
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python2.7/site-packages
Requires:
Required-by:

@vsantana
Copy link
Author

Just to confirm:

Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

-> import simplenote
-> simplenote.__version__
<- '2.0.2'

@vsantana
Copy link
Author

on

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/simplenote/simplenote.py", line 252, in get_note_list

DATA_URL + params == ' https://api.simperium.com/1/chalk-bump-f49/note/index?limit=1000&data=true'

@vsantana
Copy link
Author

vsantana commented Oct 11, 2018

More info:
self.autentication is returning None
self.username and self.password is ok.
sys.version_info == sys.version_info(major=3, minor=6, micro=4, releaselevel='final', serial=0)

@atomicules
Copy link
Collaborator

Weird. Wonder if it's something related to type of characters in username/password?

@vsantana
Copy link
Author

Seems a SSL error.
image

@vsantana
Copy link
Author

Eureka! It's related with https://stackoverflow.com/questions/35569042/ssl-certificate-verify-failed-with-python3
works fine after install certificates

@atomicules
Copy link
Collaborator

Ok. Cool. Thanks for reporting back.

@vsantana
Copy link
Author

Thanks.
Maybe try/except statement should be more specific.

@atomicules atomicules added the up for grabs Maintainer has no plans to work themselves. Feel free to tackle. label Jun 2, 2019
@atomicules
Copy link
Collaborator

Doing a review of older issues. Will rename/edit this one, but basically it's up for grabs for anyone that wants to add error handling around the absence of CA certs locally, etc.

@atomicules atomicules changed the title Python 3 support Provide better error handling/notification around improper TLS setup Jun 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easier up for grabs Maintainer has no plans to work themselves. Feel free to tackle.
Projects
None yet
Development

No branches or pull requests

2 participants