-
-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly handle unicode and byte streams with pantsd for Python 3 (#7130
) ## Problem Any test with `@ensure_daemon` fails when ran with `./pants3`. This is due to unicode issues. For example, `./pants3 test tests/python/pants_test/base:exiter_integration` will fail with: ```python Exception caught: (builtins.TypeError) File "/home/eric/pants/src/python/pants/bin/pants_loader.py", line 89, in <module> main() File "/home/eric/pants/src/python/pants/bin/pants_loader.py", line 85, in main PantsLoader.run() File "/home/eric/pants/src/python/pants/bin/pants_loader.py", line 81, in run cls.load_and_execute(entrypoint) File "/home/eric/pants/src/python/pants/bin/pants_loader.py", line 74, in load_and_execute entrypoint_main() File "/home/eric/pants/src/python/pants/bin/pants_exe.py", line 39, in main PantsRunner(exiter, start_time=start_time).run() File "/home/eric/pants/src/python/pants/bin/pants_runner.py", line 48, in run return RemotePantsRunner(self._exiter, self._args, self._env, options_bootstrapper).run() File "/home/eric/pants/src/python/pants/bin/remote_pants_runner.py", line 190, in run self._run_pants_with_retry(pantsd_handle) File "/home/eric/pants/src/python/pants/bin/remote_pants_runner.py", line 114, in _run_pants_with_retry return self._connect_and_execute(pantsd_handle.port) File "/home/eric/pants/src/python/pants/bin/remote_pants_runner.py", line 155, in _connect_and_execute result = client.execute(self.PANTS_COMMAND, *self._args, **modified_env) File "/home/eric/pants/src/python/pants/java/nailgun_client.py", line 269, in execute return self._session.execute(cwd, main_class, *args, **environment) File "/home/eric/pants/src/python/pants/java/nailgun_client.py", line 109, in execute return self._process_session() File "/home/eric/pants/src/python/pants/java/nailgun_client.py", line 80, in _process_session self._write_flush(self._stdout, payload) File "/home/eric/pants/src/python/pants/java/nailgun_client.py", line 63, in _write_flush fd.write(payload) Exception message: write() argument must be str, not bytes ``` ## Solution Use `sys.std{out,err}.buffer` with Py3. We reaffirmed in #7073 a prior decision that the `Exiter` related code should be using a bytes interface. However, we did not fix the pantsd related code because it was causing regressions. We now fix these usages. Note that in `pants_daemon.py`, we override `sys.stdout` to our own custom `_LoggerStream` object. To ensure Python 3 support, we add a `buffer` property. ## Caveats ### Exiter integration still fails on macOS `tests/python/pants_test/base:exiter_integration` will fail on macOS still, due to an upstream non fork safe osx lib (see https://bugs.python.org/issue28342). But this bug also affects Python 2. ### Python 3.7 daemon never executes See #7160.
- Loading branch information
1 parent
7555976
commit c5d4ea1
Showing
9 changed files
with
60 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
tests/python/pants_test/backend/jvm/tasks:scala_repl_integration | ||
tests/python/pants_test/backend/project_info/tasks:idea_plugin_integration | ||
tests/python/pants_test/backend/python/tasks:integration | ||
tests/python/pants_test/backend/python:integration | ||
tests/python/pants_test/base:exiter_integration | ||
tests/python/pants_test/engine/legacy:changed_integration | ||
tests/python/pants_test/engine/legacy:console_rule_integration | ||
tests/python/pants_test/engine/legacy:owners_integration | ||
tests/python/pants_test/engine:scheduler_integration | ||
tests/python/pants_test/pantsd:pantsd_integration | ||
tests/python/pants_test/projects:testprojects_integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters