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

Fix shortcuts.run crashes in text mode in python3 #133

Merged
merged 2 commits into from
Jan 8, 2020

Conversation

JayZ12138
Copy link
Contributor

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.

@JayZ12138 JayZ12138 force-pushed the 7875 branch 2 times, most recently from 39f5f01 to ee03831 Compare December 12, 2019 07:47
@coveralls
Copy link

coveralls commented Dec 12, 2019

Pull Request Test Coverage Report for Build 173

  • 12 of 12 (100.0%) changed or added relevant lines in 1 file are covered.
  • 31 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 53.395%

Files with Coverage Reduction New Missed Lines %
kobo/rpmlib.py 31 73.04%
Totals Coverage Status
Change from base Build 163: 0.1%
Covered Lines: 3185
Relevant Lines: 5965

💛 - 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.
@JayZ12138 JayZ12138 changed the title Fix shortcut.run failed in all text mode in python3 Fix shortcuts.run crashes in text mode in python3 Dec 12, 2019

# 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'
Copy link
Member

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:

Suggested change
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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, makes sense.

@JayZ12138 JayZ12138 requested review from rohanpm and negillett January 7, 2020 02:37
@JayZ12138 JayZ12138 merged commit 507cecd into release-engineering:master Jan 8, 2020
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 this pull request may close these issues.

5 participants