clint icon indicating copy to clipboard operation
clint copied to clipboard

"TypeError: coercing to Unicode" with colored output

Open smilliken opened this issue 10 years ago • 2 comments

A minor bug, but was confusing when I stumbled across it. puts(colored.red(1)) works as expected normally, but doesn't degrade correctly when colors aren't supported.

test1.py:

from clint.textui import puts, colored
puts(colored.red(1))

test2.py:

from clint.textui import puts, colored
puts(colored.red('1'))
$ python test1.py
1 (colored)
$ python test1.py | cat
TypeError: coercing to Unicode: need string or buffer, int found
$ python test2.py
1 (colored)
$ python test2.py | cat
1

smilliken avatar Feb 24 '14 22:02 smilliken

What version did you use? If I run your first test I get an AttributeError for the int value. It seems that in the current version only strings are supported.

aeby avatar May 09 '14 19:05 aeby

+1

zodman avatar Oct 14 '15 23:10 zodman