-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fix shortcuts.run crashes in text mode in python3 #133
Conversation
39f5f01
to
ee03831
Compare
Pull Request Test Coverage Report for Build 173
💛 - Coveralls |
In python3, some new args are introduced to Popen, which are 'text', 'encoding' and 'errors', when any of these args is set, Popen will enable the text mode, leading shortcuts.run to crash. This patch fix makes it recoginize these new args.
kobo/shortcuts.py
Outdated
|
||
# any of these args is passed, text mode will be enabled. | ||
is_text_mode = any([universal_newlines, text, encoding, errors]) | ||
encoding_method = encoding or 'utf-8' |
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.
To me it'd be cleaner to just reuse encoding variable, like:
encoding_method = encoding or 'utf-8' | |
encoding = encoding or 'utf-8' |
The encoding_method
name is a little awkward, it's unclear that encoding
and encoding_method
really mean the same thing except that one of them is the raw value passed by the caller and the other is the value with some default possibly applied. How about just applying the default to encoding
directly?
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.
yeah, makes sense.
In python3, some new args are introduced to Popen, which are 'text',
'encoding' and 'errors', when any of these args is set, Popen will
enable the text mode, leading shortcuts.run to crash.
This patch makes it recognize and be able to deal with these new args.