Doesn't support Unicode names
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-openstackclient |
New
|
Undecided
|
Unassigned |
Bug Description
Some of my project descriptions are in Chinese. When I openstack project list:
'ascii' codec can't encode characters in position 765-767: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/local/
result = cmd.run(
File "/usr/local/
self.
File "/usr/local/
parsed_args,
File "/usr/local/
stdout.
UnicodeEncodeError: 'ascii' codec can't encode characters in position 765-767: ordinal not in range(128)
The problem is likely in your terminal environment and not in openstack.
Please perform the following to help us diagnose the problem, run python interactively and print out the stdout encoding value, e.g.
% python
>>> import sys
>>> sys.stdout.encoding
If the value is "ascii" or "ANSI_X3.4-1968" or any other equivalent name for ASCII the problem is in your environment. You most likely do not have your LANG environment variable set correctly. LANG should be of the form:
lang_code [underscore region_code] dot encoding, for me as a US English my LANG looks like this:
en_US.UTF-8
The critical thing here is the .encoding value of UTF-8. Python when it starts up looks up your locale information and if it find an encoding value sets the encoding property of stdin, stdout and stderr to the value found in your environment, if it's not defined in your environment it defaults to ASCII. Also you should be aware this only occurs if stdin, stdout and stderr are attached to a TTY, if you redirect the encoding on these streams will default to sys defaultencoding which is set in the site.py of your Python distribution which defaults to ASCII.
Note, this only applies to Python 2, Python 3 has different semantics.