Closed privet-kitty closed 1 year ago
Hi @privet-kitty,
Thanks for reporting this issue and suggesting a solution. I plan to include your fix in an upcoming release.
I guess that environment variable should also be set/respected when running tasks that capture output in the executor like this. Would you foresee any downside with that?
@nat-n Thank you for merging!
I guess that environment variable should also be set/respected when running tasks that capture output in the executor like this. Would you foresee any downside with that?
Actually I don't quite understand the necessity that you care PYTHONIOENCODING
either in save_task_output
or exec_via_subproc
, because users can easily control the I/O of their tasks, and more importantly they know that they can without being taught (unlike poetry env info -p
problem) . However, I find no obvious downside and I'm not against that.
@privet-kitty yes, users can control it (still), though my intention is that this way they're less likely to have to think about it. Thanks for the feedback. :)
Hi. Thank you for maintaining this awesome task-runner. I ran into a problem on Windows with Japanese language environment. The minimal reproducible example would be as follows:
Put the following
pyproject.toml
under a directory whose path contains multi-byte characters (e.g.C:\Users\username\テスト
).poetry config virtualenvs.in-project true --local
andpoetry install
.poe python
and see it fail.PYTHONIOENCODING="cp932"
in advance would be a way, for example.The error would be as follows.
The cause is,
bytes.decode()
assumesutf-8
when no encoding is given, but whatpoetry env info -p
outputs is not necessarily inutf-8
. In my environment, the correct encoding iscp932
when the python output is piped. It appears to be a traditional problem onsys.stdout.encoding
, which python "wisely" decides depending on the execution environment and the output stream.[^1][^1]: For your information, the related stackoverflow posts would be Why do the sys.stdout.encoding differ when output is piped (in Python2.x)? or Setting the correct encoding when piping stdout in Python
I confirmed that the example above failed on 0.16.5 but not 0.16.4. I guess it's just because the recent changes (https://github.com/nat-n/poethepoet/commit/15edd33ae1a2900eb1c1d3b94946c3509fe1f0c5) have made it so that
_get_poetry_virtualenv
is always called. It should be an inapparent problem in older versions too.As for the solution, it would be a way, setting
PYTHONIOENCODING
toutf-8
before invokingpoetry env info -p
(https://github.com/nat-n/poethepoet/commit/67707aad5425b7262de27f1388be35f082bed344). I'm not confident about how decent this workaround is, but anyway that resolved my issue.