[Openstack-operators] python and nice utf ö ü :)

Saverio Proto zioproto at gmail.com
Wed Aug 31 13:03:14 UTC 2016


Oh,
to stick with the subject of the email you can also call the instance
for example

füöô

and this will trigger the bug anyway :)

Saverio




2016-08-31 14:54 GMT+02:00 Saverio Proto <zioproto at gmail.com>:
> Hello Matt,
>
> I am sorry, I realize now I sent a very dumb email :) I will try to
> explain my self better.
>
> The script fails to print some resources. To reproduce the bug do the following,
>
> Create a instance and name it:
>
> آشپزی ایتالیایی
>
> then just call
>
> python user-info.py <username>
>
> (of course the username is the one that created the instance)
>
> this will print all the instances, including the one with the
> problematic name. Of course you will get an Error. It will raise an
> exception and will fail.
>
> the patch I proposed shows how to get a traceback that makes sense,
> you will get something like:
>
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 0-3: ordinal not in range(128)
>
>
> Adding this two lines:
> reload(sys)
> sys.setdefaultencoding("utf-8")
>
> fixes the problem, I dont have anymore the exception
> UnicodeEncodeError and I see printed:
>
> Server: نواع-پاستاها-و-طرز-ط [3f26242c-440b-4a2e-b3ca-cb6c6c7ee8b2] - ACTIVE
>
> But on stackoverflow people say that these two lines I added are bad,
> so what should I do ? :)
>
> thank you !
>
> Saverio
>
>
>
> 2016-08-31 14:13 GMT+02:00 Matt Jarvis <matt.jarvis at datacentred.co.uk>:
>> What was your problem to start with ?
>>
>> On 31 August 2016 at 12:56, Saverio Proto <zioproto at gmail.com> wrote:
>>>
>>> Hello ops,
>>>
>>> this patch fixed my problem:
>>>
>>> https://review.openstack.org/#/c/361308/
>>>
>>> but it is an ugly hack according to:
>>>
>>>
>>> http://stackoverflow.com/questions/3828723/why-should-we-not-use-sys-setdefaultencodingutf-8-in-a-py-script
>>>
>>> anyone knows how to make it better ?
>>>
>>> Saverio
>>>
>>> _______________________________________________
>>> OpenStack-operators mailing list
>>> OpenStack-operators at lists.openstack.org
>>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators
>>
>>
>>
>> DataCentred Limited registered in England and Wales no. 05611763



More information about the OpenStack-operators mailing list