)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"469b90486f5eab721f687d6ea7c78b37aeaef618","unresolved":false,"context_lines":[{"line_number":23,"context_line":"  contains a non-ASCII character"},{"line_number":24,"context_line":""},{"line_number":25,"context_line":"Only logging.log(u\u0027error: %s\u0027, exception_to_unicode(exc)) works in all"},{"line_number":26,"context_line":"cases: ASCII or non-ASCII exception message, Python 2 and Python 3."},{"line_number":27,"context_line":""},{"line_number":28,"context_line":"Change-Id: I241b7c81c7ae3d26f81790e9180678dc9af81e22"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":1,"id":"9a80dd14_2fec51f3","line":26,"updated":"2015-03-11 16:15:32.000000000","message":"I wrote this new function because it looks like the fix proposed for the following bug doesn\u0027t work:\nhttps://bugs.launchpad.net/nova/+bug/1419905 \n\nExample on Linux with a UTF-8 locale encoding and a non-ASCII exception message:\n\n$ python2\nPython 2.7.8 (default, Nov 10 2014, 08:19:18) \n[GCC 4.9.2 20141101 (Red Hat 4.9.2-1)] on linux2\n\u003e\u003e\u003e import logging\n\u003e\u003e\u003e logging.critical(u\u0027error: %s\u0027, Exception(\u0027\\xe9\u0027.encode(\u0027utf8\u0027))\n... )\nTraceback (most recent call last):\n  File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\nUnicodeDecodeError: \u0027ascii\u0027 codec can\u0027t decode byte 0xe9 in position 0: ordinal not in range(128)","commit_id":"af9042807ebc885a18c66d86ebb3388d788da611"},{"author":{"_account_id":8122,"name":"Cyril Roelandt","email":"cyril@redhat.com","username":"cyril.roelandt.enovance"},"change_message_id":"e1df82c1e7d29ad435fd238bed290f2bb6ae4463","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Add exception_to_unicode() function"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"There is no simple way working on Python 2 and Python 3 to get the"},{"line_number":10,"context_line":"message of an exception as a Unicode string. This new functions uses an"},{"line_number":11,"context_line":"heuristic to get the encoding of the exception message. It tries UTF-8"},{"line_number":12,"context_line":"(which is a superset of ASCII), the locale encoding, or fallback to"},{"line_number":13,"context_line":"ISO-8859-1 (which never fails)."}],"source_content_type":"text/x-gerrit-commit-message","patch_set":3,"id":"9aa53dc9_b200a502","line":10,"updated":"2015-04-08 14:54:32.000000000","message":"If you need another patchset, s/an/a/.","commit_id":"53ee8719a9af2bb95585b9076abc1200f5f5dd16"}],"oslo_utils/encodeutils.py":[{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"3269c62ece0ccb3495933ddc963a5864641b5aa9","unresolved":false,"context_lines":[{"line_number":107,"context_line":"    \"\"\""},{"line_number":108,"context_line":"    # On Python 2, trying unicode(exc) is not useful: basically it tries"},{"line_number":109,"context_line":"    # str(exc).decode(\u0027ascii\u0027), whereas we can try directly to decode from"},{"line_number":110,"context_line":"    # UTF-8 (superset of ASCII)."},{"line_number":111,"context_line":"    #"},{"line_number":112,"context_line":"    # Don\u0027t use str(exc) because it fails with UnicodeEncodeError on Python 2"},{"line_number":113,"context_line":"    # if exc.__str__() returns a Unicode string"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a80dd14_4ebaf50b","line":110,"updated":"2015-03-19 18:18:52.000000000","message":"Is this true even for our exceptions where we use oslo.i18n Message objects as the strings sometimes?","commit_id":"af9042807ebc885a18c66d86ebb3388d788da611"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"c97df69354101bb9dacc1f0b5b3263ac01125be9","unresolved":false,"context_lines":[{"line_number":107,"context_line":"    \"\"\""},{"line_number":108,"context_line":"    # On Python 2, trying unicode(exc) is not useful: basically it tries"},{"line_number":109,"context_line":"    # str(exc).decode(\u0027ascii\u0027), whereas we can try directly to decode from"},{"line_number":110,"context_line":"    # UTF-8 (superset of ASCII)."},{"line_number":111,"context_line":"    #"},{"line_number":112,"context_line":"    # Don\u0027t use str(exc) because it fails with UnicodeEncodeError on Python 2"},{"line_number":113,"context_line":"    # if exc.__str__() returns a Unicode string"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a80dd14_fdd7b820","line":110,"in_reply_to":"9a80dd14_4ebaf50b","updated":"2015-03-20 15:29:04.000000000","message":"I missed an important case: Exception.args[0] can be a Unicode string. In this case, Exception.__str__() can fail because the C implementation tries to encode the Unicode string to bytes (and it fails with the default encoding, ASCII).\n\nI wrote a new version of my changeset which tries first to call exc.__unicode__(). It should now cover all cases.","commit_id":"af9042807ebc885a18c66d86ebb3388d788da611"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"f850f8038ad3ea3af9aae12b0d2d40e4222d2520","unresolved":false,"context_lines":[{"line_number":106,"context_line":"    from ISO-8859-1 (which never fails)."},{"line_number":107,"context_line":"    \"\"\""},{"line_number":108,"context_line":"    msg \u003d None"},{"line_number":109,"context_line":"    if six.PY2:"},{"line_number":110,"context_line":"        try:"},{"line_number":111,"context_line":"            msg \u003d exc.__unicode__()"},{"line_number":112,"context_line":"        except UnicodeError:"}],"source_content_type":"text/x-python","patch_set":2,"id":"1a6ced46_bcb05e8c","line":109,"updated":"2015-03-24 15:50:03.000000000","message":"Why not call unicode(exc)? Maybe a comment like u have for str(exc) would be useful?","commit_id":"52c08d28337c1043458282acd52b9036f355149f"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"87950b616993055344498f87199eaf948412cc04","unresolved":false,"context_lines":[{"line_number":106,"context_line":"    from ISO-8859-1 (which never fails)."},{"line_number":107,"context_line":"    \"\"\""},{"line_number":108,"context_line":"    msg \u003d None"},{"line_number":109,"context_line":"    if six.PY2:"},{"line_number":110,"context_line":"        try:"},{"line_number":111,"context_line":"            msg \u003d exc.__unicode__()"},{"line_number":112,"context_line":"        except UnicodeError:"}],"source_content_type":"text/x-python","patch_set":2,"id":"fa963961_62aaab1b","line":109,"in_reply_to":"1a6ced46_bcb05e8c","updated":"2015-03-26 17:02:12.000000000","message":"I tested in Python 2: unicode(Exception(b\u0027\\xff\u0027)) raised a UnicodeDecodeError because b\u0027\\xff\u0027 cannot be decoded from the default encoding (ASCII). I added a comment to explain that.","commit_id":"52c08d28337c1043458282acd52b9036f355149f"},{"author":{"_account_id":8122,"name":"Cyril Roelandt","email":"cyril@redhat.com","username":"cyril.roelandt.enovance"},"change_message_id":"e1df82c1e7d29ad435fd238bed290f2bb6ae4463","unresolved":false,"context_lines":[{"line_number":121,"context_line":"        # string not encodable to the default encoding (ASCII)"},{"line_number":122,"context_line":"        msg \u003d exc.__str__()"},{"line_number":123,"context_line":"    if isinstance(msg, six.text_type):"},{"line_number":124,"context_line":"        # On Python 3, msg should always be a Unicode string"},{"line_number":125,"context_line":"        return msg"},{"line_number":126,"context_line":""},{"line_number":127,"context_line":"    try:"}],"source_content_type":"text/x-python","patch_set":3,"id":"9aa53dc9_df2b3293","line":124,"updated":"2015-04-08 14:54:32.000000000","message":"Can we only get here in Python 3 ?","commit_id":"53ee8719a9af2bb95585b9076abc1200f5f5dd16"},{"author":{"_account_id":8122,"name":"Cyril Roelandt","email":"cyril@redhat.com","username":"cyril.roelandt.enovance"},"change_message_id":"004c4a368c54c177bb975b25ef5309177d263b0a","unresolved":false,"context_lines":[{"line_number":121,"context_line":"        # string not encodable to the default encoding (ASCII)"},{"line_number":122,"context_line":"        msg \u003d exc.__str__()"},{"line_number":123,"context_line":"    if isinstance(msg, six.text_type):"},{"line_number":124,"context_line":"        # On Python 3, msg should always be a Unicode string"},{"line_number":125,"context_line":"        return msg"},{"line_number":126,"context_line":""},{"line_number":127,"context_line":"    try:"}],"source_content_type":"text/x-python","patch_set":3,"id":"7aaa499b_4c8344cd","line":124,"in_reply_to":"9aa53dc9_06e713b1","updated":"2015-04-13 12:57:34.000000000","message":"I find the comment confusing, then. As it starts with \"On Python 3\", one may think that we can only get in this branch when running Python 3 - see what I mean ?","commit_id":"53ee8719a9af2bb95585b9076abc1200f5f5dd16"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"ec64f3459e1b25481b8c99a5b1844811ce471b86","unresolved":false,"context_lines":[{"line_number":121,"context_line":"        # string not encodable to the default encoding (ASCII)"},{"line_number":122,"context_line":"        msg \u003d exc.__str__()"},{"line_number":123,"context_line":"    if isinstance(msg, six.text_type):"},{"line_number":124,"context_line":"        # On Python 3, msg should always be a Unicode string"},{"line_number":125,"context_line":"        return msg"},{"line_number":126,"context_line":""},{"line_number":127,"context_line":"    try:"}],"source_content_type":"text/x-python","patch_set":3,"id":"9aa53dc9_06e713b1","line":124,"in_reply_to":"9aa53dc9_df2b3293","updated":"2015-04-08 16:17:28.000000000","message":"No, the __str__() method of crazy exceptions can return Unicode: see for example StrException(u\u0027unicode \\xe9\\u20ac\u0027).__str__() in unit tests.\n\nI would like to ensure that exception_to_unicode() never fails on unicode error. Avoiding a check on Python 2 or Python 3 may introduce subtle bug on such crazy exceptions.","commit_id":"53ee8719a9af2bb95585b9076abc1200f5f5dd16"}],"oslo_utils/tests/tests_encodeutils.py":[{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"3269c62ece0ccb3495933ddc963a5864641b5aa9","unresolved":false,"context_lines":[{"line_number":104,"context_line":"        self.assertNotEqual(text, result)"},{"line_number":105,"context_line":"        self.assertNotEqual(six.b(\"foo\\xf1bar\"), result)"},{"line_number":106,"context_line":""},{"line_number":107,"context_line":"    def test_exception_to_unicode(self):"},{"line_number":108,"context_line":"        # Exception cannot be used directly: Exception(u\u0027\\xe9\u0027).__str__()"},{"line_number":109,"context_line":"        # raises an UnicodeEncodeError on Python 2."},{"line_number":110,"context_line":"        class StrException(Exception):"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a80dd14_4e1675f3","line":107,"updated":"2015-03-19 18:18:52.000000000","message":"Can you ad some tests using the i18n translatable Message objects? They\u0027re a subclass of unicode, but I want to make sure that none of these conversions cause them to lose data. We\u0027ll need tests that use % to provide interpolation values for the translatable strings, for example.","commit_id":"af9042807ebc885a18c66d86ebb3388d788da611"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"c97df69354101bb9dacc1f0b5b3263ac01125be9","unresolved":false,"context_lines":[{"line_number":104,"context_line":"        self.assertNotEqual(text, result)"},{"line_number":105,"context_line":"        self.assertNotEqual(six.b(\"foo\\xf1bar\"), result)"},{"line_number":106,"context_line":""},{"line_number":107,"context_line":"    def test_exception_to_unicode(self):"},{"line_number":108,"context_line":"        # Exception cannot be used directly: Exception(u\u0027\\xe9\u0027).__str__()"},{"line_number":109,"context_line":"        # raises an UnicodeEncodeError on Python 2."},{"line_number":110,"context_line":"        class StrException(Exception):"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a80dd14_dd5f54e3","line":107,"in_reply_to":"9a80dd14_4e1675f3","updated":"2015-03-20 15:29:04.000000000","message":"Which exception class does store directly oslo_i18n.Message objects? NovaException casts the Message to Unicode, the Unicode string is passed to Exception constructor (parent class), the Message class is not stored.\n\nI added new tests which should cover all kind of exceptions: __str__ only, __unicode__ only, __str__ and __unicode__, __str__ and __unicode__ and __str__ raises an exception.","commit_id":"af9042807ebc885a18c66d86ebb3388d788da611"}]}
