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

overrides check_output returning bytes by default #838

Closed
wants to merge 2 commits into from
Closed

overrides check_output returning bytes by default #838

wants to merge 2 commits into from

Conversation

tijko
Copy link
Contributor

@tijko tijko commented Jun 14, 2016

On python 3.x > when running the .git-pre-commit the subprocess.check_output returns bytes by default. This overrides the default behavior by setting the universal_newlines to True.

@@ -10,7 +10,8 @@ import sys


def main():
out = subprocess.check_output("git diff --cached --name-only", shell=True)
out = subprocess.check_output("git diff --cached --name-only", shell=True,
universal_newlines=True)
Copy link
Owner

Choose a reason for hiding this comment

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

what happens if you do this instead?

- files = [x for x in out.split('\n') if x.endswith('.py') and
+ files = [x for x in out.split(b'\n') if x.endswith('.py') and

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converting the string arguments to bytes would work correct the error too.

files = [x for x in out.split(b'\n') if x.endswith(b'.py') and

@tijko tijko closed this Jun 16, 2016
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.

None yet

2 participants