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 fixes - add open() backport stage 1 #6290

Merged
merged 16 commits into from Aug 2, 2018

Conversation

Projects
None yet
2 participants
@Eric-Arellano
Copy link
Contributor

Eric-Arellano commented Aug 1, 2018

Ensures these folders use Python 3 semantics for opening files:

  • src/base/
  • src/bin/
  • src/binaries/
  • src/build_graph/
  • src/cache/
  • src/console/
  • src/core_tasks/
  • src/engine/
  • src/fs/
  • src/goal/
  • src/help/
  • src/init/
  • src/invalidation/
  • src/ivy/
  • src/java/
  • src/net/
  • src/option/
  • src/pantsd/
  • src/process/
  • src/releases/
@@ -161,7 +161,7 @@ def _tty_stdio(cls, env):
'please file a bug at http://github.com/pantsbuild/pants'
.format([stdin_ttyname, stdout_ttyname, stderr_ttyname])
)
with open(stdin_ttyname, 'rb+wb', 0) as tty:
with open(stdin_ttyname, 'rb+', 0) as tty:

This comment has been minimized.

@Eric-Arellano

Eric-Arellano Aug 1, 2018

Contributor

rb+wb isn't allowed in Py3. I think rb+ gets the job done. See https://stackoverflow.com/questions/6648493/open-file-for-both-reading-and-writing

from contextlib import closing, contextmanager

import six
from io import StringIO

This comment has been minimized.

@Eric-Arellano

Eric-Arellano Aug 1, 2018

Contributor

six.StringIO is not safe. It has different semantics in Py2. We'll need to strip all remaining instances.

@stuhood

stuhood approved these changes Aug 2, 2018

Copy link
Member

stuhood left a comment

Thanks!

@stuhood stuhood merged commit 1702d98 into pantsbuild:master Aug 2, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:py3-fixes_open-stage1 branch Aug 2, 2018

stuhood added a commit that referenced this pull request Aug 4, 2018

Python 3 fixes - add open() backport stage 2 (#6291)
Ensures these folders use Python 3 semantics for opening files.

- src/backend/codegen
- src/backend/docgen
- src/backend/graph_info
- src/backend/jvm
- src/backend/native
- src/backend/project_info
- src/backend/python
- src/reporting/
- src/rules
- src/scm/
- src/source/
- src/stats/
- src/subsystem/
- src/task/
- src/util/
- test/ (root)
- test/tasks
- test/testutils

These also were mostly ported in stage 1, but I realized the subfolders weren't ported:
- src/pantsd/
- src/java/
- src/net/
- src/engine/

### Ignores safe_open()
`util/dirutil.py` was not ported because it's `safe_open()` function is used throughout the codebase. That will be a separate PR.

--

See #6290 for stage 1.

stuhood added a commit that referenced this pull request Aug 6, 2018

Python 3 fixes - add open() backport to safe_open() (#6304)
Final stage of adding Python 3 open semantics. Builds off of #6291, #6295, and #6290.

CMLivingston pushed a commit to CMLivingston/pants that referenced this pull request Aug 27, 2018

Python 3 fixes - add open() backport stage 1 (pantsbuild#6290)
Ensures these folders use Python 3 semantics for opening files:

- src/base/
- src/bin/
- src/binaries/
- src/build_graph/
- src/cache/
- src/console/
- src/core_tasks/
- src/engine/
- src/fs/
- src/goal/
- src/help/
- src/init/
- src/invalidation/
- src/ivy/
- src/java/
- src/net/
- src/option/
- src/pantsd/
- src/process/
- src/releases/

CMLivingston pushed a commit to CMLivingston/pants that referenced this pull request Aug 27, 2018

Python 3 fixes - add open() backport stage 2 (pantsbuild#6291)
Ensures these folders use Python 3 semantics for opening files.

- src/backend/codegen
- src/backend/docgen
- src/backend/graph_info
- src/backend/jvm
- src/backend/native
- src/backend/project_info
- src/backend/python
- src/reporting/
- src/rules
- src/scm/
- src/source/
- src/stats/
- src/subsystem/
- src/task/
- src/util/
- test/ (root)
- test/tasks
- test/testutils

These also were mostly ported in stage 1, but I realized the subfolders weren't ported:
- src/pantsd/
- src/java/
- src/net/
- src/engine/

### Ignores safe_open()
`util/dirutil.py` was not ported because it's `safe_open()` function is used throughout the codebase. That will be a separate PR.

--

See pantsbuild#6290 for stage 1.

CMLivingston pushed a commit to CMLivingston/pants that referenced this pull request Aug 27, 2018

cosmicexplorer added a commit that referenced this pull request Sep 10, 2018

Python 3 fixes - add open() backport stage 1 (#6290)
Ensures these folders use Python 3 semantics for opening files:

- src/base/
- src/bin/
- src/binaries/
- src/build_graph/
- src/cache/
- src/console/
- src/core_tasks/
- src/engine/
- src/fs/
- src/goal/
- src/help/
- src/init/
- src/invalidation/
- src/ivy/
- src/java/
- src/net/
- src/option/
- src/pantsd/
- src/process/
- src/releases/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment