Project

General

Profile

Actions

Bug #6537

open

Unicode bug on api client

Added by Benoît PECCATTE about 9 years ago. Updated over 6 years ago.

Status:
New
Priority:
N/A
Assignee:
-
Category:
Rudder API & CLI
Target version:
Severity:
Major - prevents use of part of Rudder | no simple workaround
UX impact:
User visibility:
Infrequent - complex configurations | third party integrations
Effort required:
Priority:
34
Name check:
Fix check:
Regression:

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)

Actions

Also available in: Atom PDF