[ https://issues.apache.org/jira/browse/LIBCLOUD-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16368072#comment-16368072 ]
Connor Osborn commented on LIBCLOUD-306: ---------------------------------------- Ran into this issue, and it got the better of my curiosity. The cause is that libcloud doesn't have python 2 compatible {{__repr__}} methods. In python 2, the {{repr }}builtin expects a {{__repr__}} method which returns an ascii string (or something coercible to an ascii string). It's required because {{repr}} will translate the result of {{X.__repr__() }}to ascii. In the case of [Node.__repr__|[https://github.com/apache/libcloud/blob/408caa9c95a197578baede0a5a1476e9201486e7/libcloud/compute/base.py#L260-L266]|https://github.com/apache/libcloud/blob/408caa9c95a197578baede0a5a1476e9201486e7/libcloud/compute/base.py#L260-L266].], if the node's name contains characters outside of ascii, then whenever {{repr(node)}} is called the unicode string returned from {{__repr__}} will fail to be encoded as ascii. This gets more complicated if you try and support python 3, because python 3's {{__repr__}} should always do the opposite - return unicode strings. The builtin {{str}} has all the same caveats. This can also easily be replicated by stubbing out a simple class: {code:java} class Foo: def __repr__(self): return u'\xe0' > repr(Foo()) > str(Foo()){code} > XML response with utf-8 charset break thing with python 2 > --------------------------------------------------------- > > Key: LIBCLOUD-306 > URL: https://issues.apache.org/jira/browse/LIBCLOUD-306 > Project: Libcloud > Issue Type: Bug > Environment: ubuntu 12.04, python 2.7, opennebula 3.8 > Reporter: Guillaume ZITTA > Priority: Critical > Attachments: debug.log, test_utf.py, utf-8_python2.patch, > utf-8_python2_xml.workaround.patch > > > We have an opennebula with French accents in networks names. > Listing networks leads to a crash because of these accents in the XML > response of the cloud. -- This message was sent by Atlassian JIRA (v7.6.3#76005)