Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cuvner is incompatible with ansicolors 1.1.6 #7

Open
exarkun opened this issue May 30, 2017 · 9 comments
Open

cuvner is incompatible with ansicolors 1.1.6 #7

exarkun opened this issue May 30, 2017 · 9 comments

Comments

@exarkun
Copy link

exarkun commented May 30, 2017

(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.

@meejah meejah added the bug label May 30, 2017
@meejah
Copy link
Owner

meejah commented May 30, 2017

Hmm, looks like https://github.com/jonathaneunice/colors/blob/master/colors/colors.py#L109 should be a unicode literal to work properly on Python2?

@exarkun
Copy link
Author

exarkun commented May 30, 2017

Seems plausible - but the docstring for color makes it unclear whether the function is meant to operate on bytes or unicode.

@exarkun
Copy link
Author

exarkun commented May 30, 2017

otoh, reading the return docs suggests yes it should work on unicode.

@exarkun
Copy link
Author

exarkun commented May 30, 2017

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.

@meejah
Copy link
Owner

meejah commented May 30, 2017

Looks to me like this was unintended fallout from this commit: jonathaneunice/colors@67dd97f#diff-3358adf77afc6138373d66e0d18cd3b6L101

...because: str + unicode + str will be a unicode, but str.format(unicode) will not be...

@meejah
Copy link
Owner

meejah commented May 30, 2017

"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...

@meejah
Copy link
Owner

meejah commented May 30, 2017

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).

@meejah
Copy link
Owner

meejah commented May 30, 2017

I guess for now I can pin cuvner to 1.0.2

meejah added a commit that referenced this issue May 30, 2017
@meejah
Copy link
Owner

meejah commented May 30, 2017

Okay, I did that and released 17.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants