jtushman / pivotal_tools

geeky command-line interface with additional scrum, planning poker, and changelog generation features
http://jtushman.github.io/blog/2013/08/15/introducing-pivotal-tools/
64 stars 26 forks source link

Non-ASCII characters in project name causes error #9

Open seniorio opened 11 years ago

seniorio commented 11 years ago

Hey, looks like I’m getting Python encoding errors if my Pivotal project name has a non-ASCII character in it, specifically ‘é’ in my case.

The error:

$ pivotal_tools changelog
Select a Project:
[1] An ASCII Project Name
[2] Another ASCII Project Name
Traceback (most recent call last):
  File "/usr/local/bin/pivotal_tools", line 9, in <module>
    load_entry_point('pivotal-tools==0.14', 'console_scripts', 'pivotal_tools')()
  File "/usr/local/lib/python2.7/dist-packages/pivotal_tools/cli.py", line 508, in main
    project = prompt_project(arguments)
  File "/usr/local/lib/python2.7/dist-packages/pivotal_tools/cli.py", line 353, in prompt_project
    print "[{}] {}".format(idx+1, project.name)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 4: ordinal not in range(128)

The line in question:

print "[{}] {}".format(idx+1, project.name)

Adding the unicode u does fix the problem:

print u"[{}] {}".format(idx+1, project.name)

But I guess this will be a tool-wide issue. Happy to submit a PR if needed, depending on what you think the correct way to fix this is.

Cheers :)

vielmath commented 11 years ago

I have the same issue but in stories content.

jtushman commented 11 years ago

Cool. I'll get on this hopefully soon. PR are always appreciated. Is it really as simple as adding a u -- are there other approaches that we should consider?

seniorio commented 11 years ago

Unfortunately I’m not a Python dev so don’t want to accidentally give bad advice; this is an interesting read: http://blog.notdot.net/2010/07/Getting-unicode-right-in-Python

I’ll keep looking for best-practices in the meantime and submit a PR if I find something.

Cheers!