sparklines icon indicating copy to clipboard operation
sparklines copied to clipboard

On python2 errors our when output is piped to another process

Open talwrii opened this issue 7 years ago • 2 comments

This appears to to be a problem for python3

Repro

--- 16-09-21T14:42:48  0 0:00 tom@laptop:/home/tom/active/sparklines (master|✔)
python2 -m sparklines 1 2 3 | cat
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/tom/active/sparklines/sparklines/__main__.py", line 125, in <module>
    main()
  File "/home/tom/active/sparklines/sparklines/__main__.py", line 121, in main
    print(line)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
--- 16-09-21T14:42:29  0 0:00 tom@laptop:/home/tom/active/sparklines (master|✔)
python3 -m sparklines 1 2 3 | cat
▁▄█
--- 16-09-21T14:44:43  0 0:01 tom@laptop:/home/tom/active/sparklines (master|✔)
git log -n 1 | cat
commit 2c630da5f7ddc2be8259f66609f84182a1959530
Author: Dinu Gherman <[email protected]>
Date:   Tue Jul 19 15:22:10 2016 +0200

    Enabled repeated use of option -e
--- 16-09-21T14:42:48  0 0:00 tom@laptop:/home/tom/active/sparklines (master|✔)
python --version
Python 2.7.12+

I get the impression this could be a little fiddly to fix (on python2 you want .encode('utf8') (probably)` but you get problems with bytestrings if you do this in python3.

talwrii avatar Sep 21 '16 19:09 talwrii

Thanks! Will have a look, but with rather low-priority.

deeplook avatar Sep 22 '16 15:09 deeplook

Sorry for the long delay!!! As meanwhile Python 2 has reached end-of-life I prefer to drop any "support" for it.

deeplook avatar May 26 '20 17:05 deeplook

Closing with repeated reference to Python 2 EOL, after way too much time...

deeplook avatar Sep 14 '23 21:09 deeplook