cuvner
cuvner copied to clipboard
cuvner is incompatible with ansicolors 1.1.6
(txkube) exarkun@baryon:~/Work/LeastAuthority/txkube$ git diff origin/master... | cuv diff -
skip: MANIFEST.in
skip: README.rst
skip: src/txkube/extra-1.5.json
b/src/txkube/__init__.py
"IObject", "IKubernetes", "IKubernetesClient",
"KubernetesError", "UnrecognizedVersion", "UnrecognizedKind",
- "v1", "v1beta1", "iobject_from_raw", "iobject_to_raw",
Traceback (most recent call last):
File "/home/exarkun/Environments/txkube/bin/cuv", line 11, in <module>
sys.exit(cuv())
File "/home/exarkun/Environments/txkube/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/home/exarkun/Environments/txkube/local/lib/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/exarkun/Environments/txkube/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/exarkun/Environments/txkube/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/exarkun/Environments/txkube/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/exarkun/Environments/txkube/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/exarkun/Environments/txkube/local/lib/python2.7/site-packages/cuv/cli.py", line 315, in diff
diff_color(input_file, ctx.obj)
File "/home/exarkun/Environments/txkube/local/lib/python2.7/site-packages/cuv/diff.py", line 117, in diff_color
pager.echo(colors.color(u'\u258f', fg='green'), nl=False, color=True)
File "/home/exarkun/Environments/txkube/local/lib/python2.7/site-packages/colors/colors.py", line 109, in color
return '\x1b[{0}m{1}\x1b[0m'.format(_join(*codes), s)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u258f' in position 0: ordinal not in range(128)
(txkube) exarkun@baryon:~/Work/LeastAuthority/txkube$
This goes away when I downgrade ansicolors to 1.0.2.
Hmm, looks like https://github.com/jonathaneunice/colors/blob/master/colors/colors.py#L109 should be a unicode literal to work properly on Python2?
Seems plausible - but the docstring for color
makes it unclear whether the function is meant to operate on bytes or unicode.
otoh, reading the return
docs suggests yes it should work on unicode.
Merely changing that string to a unicode literal will break usage like color(encoded_utf8_bytes)
though. Really, "bytes or unicode" is not a happy type to have to work with.
Looks to me like this was unintended fallout from this commit: https://github.com/jonathaneunice/colors/commit/67dd97f9edf4ff527bd1ae1d23735f4c9ebad35a#diff-3358adf77afc6138373d66e0d18cd3b6L101
...because: str + unicode + str
will be a unicode, but str.format(unicode)
will not be...
"Yes" to your last comment. Hmm... I'll file an issue on colors and see what we come up with? But this will just not work, ever: "something {}".format(u"\u258f")
and yeah the docstring says I should be able to give it a unicode string and get a unicode back...
Hmm, maybe @jonathaneunice can comment here? It seems colors isn't using the github bugtracker (and I don't see any other thing being used).
I guess for now I can pin cuvner to 1.0.2
Okay, I did that and released 17.3.0