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

UnicodeEncodeError thrown in pull list #45

Conversation

leandro-lucarella-sociomantic
Copy link
Contributor

Traceback (most recent call last):
  File "/usr/local/bin/git-hub", line 1569, in <module>
    main()
  File "/usr/local/bin/git-hub", line 1563, in main
    args.run(parser, args)
  File "/usr/local/bin/git-hub", line 522, in check_config_and_run
    cmd.run(parser, args)
  File "/usr/local/bin/git-hub", line 745, in run
    cls.print_issue(issue)
  File "/usr/local/bin/git-hub", line 668, in print_issue
    **issue)
  File "/usr/local/bin/git-hub", line 69, in infof
    sys.stdout.write(fmt.format(*args, **kwargs) + '\n')
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 31: ordinal not in range(128)

The printed pull request has a ... in it's title which is apparently encoded as unicode ellipsis.

@leandro-lucarella-sociomantic
Copy link
Contributor

Fix attached. Thanks for the report!

@mihails-strasuns-sociomantic

Fix is stil incomplete:

$ git hub pull new
Traceback (most recent call last):
  File "/usr/bin/git-hub", line 1600, in <module>
    main()
  File "/usr/bin/git-hub", line 1594, in main
    args.run(parser, args)
  File "/usr/bin/git-hub", line 527, in check_config_and_run
    cmd.run(parser, args)
  File "/usr/bin/git-hub", line 1026, in run
    cls.push(head, remote_head, force=args.force)
  File "/usr/bin/git-hub", line 946, in push
    config.forkremote)
  File "/usr/bin/git-hub", line 74, in infof
    localeprintf(sys.stdout, fmt, *args, **kwargs)
  File "/usr/bin/git-hub", line 63, in localeprintf
    msg = fmt.decode(encoding, 'replace').format(*args, **kwargs) + '\n'
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

(have added unicode stuff to branch name, commit message and pull request description at once)

@leandro-lucarella-sociomantic
Copy link
Contributor

On Thu, Oct 17, 2013 at 05:05:12AM -0700, mihails-strasuns-sociomantic wrote:

Fix is stil incomplete:

$ git hub pull new
Traceback (most recent call last):
  File "/usr/bin/git-hub", line 1600, in <module>
    main()
  File "/usr/bin/git-hub", line 1594, in main
    args.run(parser, args)
  File "/usr/bin/git-hub", line 527, in check_config_and_run
    cmd.run(parser, args)
  File "/usr/bin/git-hub", line 1026, in run
    cls.push(head, remote_head, force=args.force)
  File "/usr/bin/git-hub", line 946, in push
    config.forkremote)
  File "/usr/bin/git-hub", line 74, in infof
    localeprintf(sys.stdout, fmt, *args, **kwargs)
  File "/usr/bin/git-hub", line 63, in localeprintf
    msg = fmt.decode(encoding, 'replace').format(*args, **kwargs) + '\n'
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

(have added unicode stuff to branch name, commit message and pull
request description at once)

Mmmm, strange, everything coming from github seems to be UTF-8 encoded,
so I don't know how it can be different with other information coming
from there. I'll investigate.

@mihails-strasuns-sociomantic

@leandro-lucarella-sociomantic You can find a branch in my playground fork with cyrillic name. Trying to make a pull off it results in error I have posted.

@leandro-lucarella-sociomantic
Copy link
Contributor

On Thu, Oct 17, 2013 at 08:14:27AM -0700, mihails-strasuns-sociomantic wrote:

@leandro-lucarella-sociomantic You can find a branch in my playground
fork with cyrillic name. Trying to make a pull off it results in error
I have posted.

Thanks, I have reproduced the problem with a branch name using some
unicode chars. Fixing that will be (is) a nightmare, partly because I
didn't wrote the program with encodings in mind and partly because
Python 2 doesn't help at all to do so (Python 3 fortunately fixes this
problem). In particular several modules are making this very hard (json,
and urllib2 on top of the list).

Basically we need to add the u prefix to almost every string literal
and convert to unicode every input of the program and then encode in the
appropriate encoding for every output of the program (console and HTTP
requests).

I'm inclined to solve this issue as it is and leaving a proper encoding
fix for the future. I've been the whole afternoon trying "simple" fixes
and couldn't get it to work.

@mihails-strasuns-sociomantic

Ok, merging this as a quick fix for this specific issue and leaving full scale solution up to #46

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

Successfully merging this pull request may close these issues.

2 participants