| Summary: | >=app-portage/layman-2.2.0 -Lv throws UnicodeEncodeError under Python 2.7 if stdout redirected | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | Daniel Dawson <danielcdawson> |
| Component: | Current packages | Assignee: | Layman Overlay Manager project <layman> |
| Status: | RESOLVED OBSOLETE | ||
| Severity: | normal | CC: | g2du-mail, jstein |
| Priority: | Normal | ||
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Package list: | Runtime testing required: | --- | |
| Attachments: | emerge --info | ||
Also happens for me with layman 2.4.2 (used to see this type of error for firefox too). A workaround is to also redirect stderr to the same fd as stdout.
# qlist -ICv layman python-exec eselect-python
app-portage/layman-2.4.2-r1
dev-lang/python-exec-2.4.6
app-eselect/eselect-python-20171204
1) Select python2.7 as the default
2) # layman -L -v -N >/tmp/overylays.txt
Traceback (most recent call last):
File "/usr/lib/python-exec/python2.7/layman", line 46, in <module>
main()
File "/usr/lib64/python2.7/site-packages/layman/cli.py", line 196, in __call__
result += getattr(self, action[1])()
File "/usr/lib64/python2.7/site-packages/layman/cli.py", line 370, in ListRemote
list_printer.print_shortlist(info, complain=_complain)
File "/usr/lib64/python2.7/site-packages/layman/cli.py", line 67, in print_shortlist
self.print_overlay(summary, supported, official, complain)
File "/usr/lib64/python2.7/site-packages/layman/cli.py", line 95, in print_overlay
self.output.warn(summary, 1)
File "/usr/lib64/python2.7/site-packages/layman/output.py", line 200, in warn
print(" %s %s" % (self.color_func('yellow', '*'),i), file=self.std_out)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-11: ordinal not in range(128)
Workaround:
# layman -L -v -N >/tmp/root/overylays.txt 2>&1
works as expected
PS. Is it expected or desired that selecting a pyhton version changes the behavior of what eselect pyhton <number> does:
# eselect python list
Available Python interpreters, in order of preference:
[1] python2.7
[2] python3.5
[3] python3.6
# eselect python set 3
# eselect python list
Available Python interpreters, in order of preference:
[1] python3.6
[2] python2.7
[3] python3.5
and then
# eselect python set 3
selects python3.5
python 2.7 is no longer supported |
Created attachment 473690 [details] emerge --info Under Python 2.7, I find that $ layman -Lv works fine, but $ layman -Lv | less or any other pipe or redirection yields only partial output, stopping just before a line containing non-ASCII characters, with this message: Traceback (most recent call last): File "/usr/lib/python-exec/python2.7/layman", line 46, in <module> main() File "/usr/lib64/python2.7/site-packages/layman/cli.py", line 196, in __call__ result += getattr(self, action[1])() File "/usr/lib64/python2.7/site-packages/layman/cli.py", line 370, in ListRemote list_printer.print_shortlist(info, complain=_complain) File "/usr/lib64/python2.7/site-packages/layman/cli.py", line 67, in print_shortlist self.print_overlay(summary, supported, official, complain) File "/usr/lib64/python2.7/site-packages/layman/cli.py", line 95, in print_overlay self.output.warn(summary, 1) File "/usr/lib64/python2.7/site-packages/layman/output.py", line 200, in warn print(" %s %s" % (self.color_func('yellow', '*'),i), file=self.std_out) UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-11: ordinal not in range(128) As the summary suggests, I also determined this doesn't happen before 2.2.0. But I guess that's because it doesn't try to output non-English descriptions. I'm not sure how this can be fixed. However, running layman under Python 3 avoids it.