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 Idea plugin unicode issues with Python 3 #7141

Merged
merged 3 commits into from
Jan 24, 2019

Conversation

Eric-Arellano
Copy link
Contributor

No description provided.

It was being returned as bytes, so Mustache would generate a unicode file with `b''` in the prefix, which led to an error of `malformed input`.
@@ -160,7 +163,7 @@ def generate_project(self):
def _generate_to_tempfile(self, generator):
"""Applies the specified generator to a temp file and returns the path to that file.
We generate into a temp file so that we don't lose any manual customizations on error."""
with temporary_file(cleanup=False) as output:
with temporary_file(cleanup=False, binary_mode=False) as output:
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like we should probably add the deprecation of unspecified binary_mode for temporary_file() to #7120?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one is tricky. temporary_file defaults to binary mode in the std lib, but indeed most of our use cases are unicode. We have to decide between consistency with our own (proposed) internal APIs vs. consistency with the standard library. I think I would advocate changing the default to unicode, but am not as convinced as I am with the functions we're changing in #7120.

Also now that I think back to it, I think temporary_file is why across the board we chose to default to binary, even though it doesn't make sense in most contexts. I didn't yet know the codebase well, so just defaulted to how temporary_file did things when considering the other functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, we could start just by requiring the argument to be explicitly specified in #7120, and then leave it as an open question on #7121?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds reasonable to me. If you don't mind, I agree then that temporary_file would be great to add to #7120!

Copy link
Contributor

Choose a reason for hiding this comment

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

About to happen! #7120 (comment)

@Eric-Arellano Eric-Arellano merged commit 96c96e8 into pantsbuild:master Jan 24, 2019
@Eric-Arellano Eric-Arellano deleted the fix-idea-plugin-py3 branch January 24, 2019 15:59
cosmicexplorer added a commit that referenced this pull request Jan 25, 2019
### Problem

See #7150. The idea plugin gen integration test became flaky on py3 as of #7141.

### Solution

Blacklist test on py3 as per [slack discussion](https://pantsbuild.slack.com/archives/CBNMV1LRH/p1548436157036300).
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.

3 participants