Bug #6537
openUnicode bug on api client
Description
Duplicated from https://github.com/Normation/rudder-api-client/issues/4
Hi,
one problem I found is that non-ascii characters can completely break the processing.
The resulting error message:
$ /usr/local/bin/rudder\-cli directives list > d.list
Traceback (most recent call last):
File "/Users/floh/git/rudder-api-client/cli/rudder-cli", line 392, in <module>
print(json.dumps(res, ensure_ascii=False, indent=4, sort_keys=True))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 174797: ordinal not in range(128)
Actually, I think this only occurs in case of a pipe/redirect, so it might in parts turn out to be a python issue.
$ python
imPython 2.7.9 (default, Dec 11 2014, 02:36:08)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.stdout.encoding
UTF-8
if i don't use any pipe / redirection, the list is printed, but then it's so big i can't look at it.
The relevant piece of http://stackoverflow.com/questions/5760936/handle-wrongly-encoded-character-in-python-unicode-string seems to be
"You have to convert your unicode string into a standard string using some encoding e.g. utf-8:
some_unicode_string.encode('utf-8')"
(double-re-back-forth-encoding)
Hand me dd and EBCDIC.
I've changed the "ensure_ascii=False" in rudder-cli to a "true" and this is a workaround for now (disclaimer: i'm just deleting objects)
Updated by Benoît PECCATTE almost 9 years ago
- Project changed from Rudder to Rudder tools
- Category changed from API to Rudder API & CLI
- Target version set to master
Updated by Benoît PECCATTE almost 9 years ago
- Status changed from New to In progress
- Assignee set to Benoît PECCATTE
Updated by Alexis Mousset almost 8 years ago
- Status changed from In progress to New
Updated by Jonathan CLARKE over 7 years ago
- Severity set to Major - prevents use of part of Rudder | no simple workaround
- User visibility set to Infrequent - complex configurations | third party integrations
- Priority set to 21