-
Notifications
You must be signed in to change notification settings - Fork 237
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
Python 3 support [WIP] #184
base: master
Are you sure you want to change the base?
Conversation
@@ -1 +1 @@ | |||
1.40.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Faced an issue due to the added newline to the end of this file.
In workflow/web.py:28
, __version__
gets set to "2.0.0\n"
, which leads to a newline appearing in USER_AGENT
:
alfred-workflow/workflow/web.py
Lines 28 to 31 in 14f5c09
__version__ = open(os.path.join(os.path.dirname(__file__), 'version')).read() | |
USER_AGENT = ('Alfred-Workflow/' + __version__ + | |
' (+http://www.deanishe.net/alfred-workflow)') |
USER_AGENT
is directly used for the User-Agent
header in all requests. On my machine, the requests
library doesn't unfold the newline, resulting in urllib.error.HTTPError: HTTP Error 400: Header Folding
for every request.
I've taken a pass at porting the existing code to Python 3, since it seems like the latest version of macOS has broken a lot of workflows that rely on this (excellent) library. At this point it would be helpful to get feedback on the direction (or help spotting things I've missed).
I started by going test-by-test looking for failures and resolving them incrementally. Kudos on the excellent testing suite with 100% coverage, because it made regressions easy to spot. All the
tox
tests pass on Python 3.7, 3.8, and 3.9.There are probably still some places where we do encode/decode hopscotch unnecessarily, but I think it all at least works. I've tested this locally on a workflow that has "vendored" the
workflow/
module into its own code, but haven't tested anything that installs this package as a dependency.I did have to drop the dependency on pytest-httpbin, because I couldn't figure out how to get that to run on Python 3. (traceback) That means the test suite hits the live instance of httpbin.org, which is not great.
I made a first pass at updating the documentation too, but a lot of the examples still need to be reworked.
TODO