)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":177,"name":"Alex Meade","email":"mr.alex.meade@gmail.com","username":"alex-meade"},"change_message_id":"e4fbbb5c275e091849c9bcfe8409968aa293586c","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Encode error messages before sending them to stdout"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"When an error with non-ascii characters is caught by glanceclient, it"},{"line_number":10,"context_line":"fails at printing it and exists with a UnicodeEncodedError. This patch"},{"line_number":11,"context_line":"encodes errors\u0027 messages using strutils before sending them to stdout."},{"line_number":12,"context_line":""},{"line_number":13,"context_line":"Fixes bug: #1200206"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":3,"id":"AAAAQn%2F%2Fvrs%3D","line":10,"updated":"2013-07-24 01:31:53.000000000","message":"Did you mean \u0027exits\u0027?","commit_id":"46787a5dbe35928055a7f3d0096630b06cfcba66"}],"glanceclient/shell.py":[{"author":{"_account_id":1390,"name":"Paul Bourke","email":"pauldbourke@proton.me","username":"pauldbourke"},"change_message_id":"09956e1db6f847099104c3f17c09174625196a56","unresolved":false,"context_lines":[{"line_number":481,"context_line":"            # NOTE(flaper87): This might fail"},{"line_number":482,"context_line":"            # if non-ascii characters are present"},{"line_number":483,"context_line":"            # in the error."},{"line_number":484,"context_line":"            error \u003d str(e)"},{"line_number":485,"context_line":"        print \u003e\u003e sys.stderr, strutils.safe_encode(error)"},{"line_number":486,"context_line":"        sys.exit(1)"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAAP3%2F%2FpQE%3D","line":484,"updated":"2013-07-15 13:11:14.000000000","message":"I don\u0027t fully understand the intention of this if/else - the first comment says \u0027don\u0027t call str(e) directly\u0027, yet if there\u0027s no message attr we do just that?\n\nIf it has potential to fail should we have a try/except?","commit_id":"635feb616e483aacc59cf18f73c697b052923572"},{"author":{"_account_id":6159,"name":"Flavio Percoco Premoli","display_name":"flaper87","email":"flavio.percoco@flyrlabs.com","username":"flaper87"},"change_message_id":"d296518ebdaa525b20beffe4d13a0106d6f1d080","unresolved":false,"context_lines":[{"line_number":481,"context_line":"            # NOTE(flaper87): This might fail"},{"line_number":482,"context_line":"            # if non-ascii characters are present"},{"line_number":483,"context_line":"            # in the error."},{"line_number":484,"context_line":"            error \u003d str(e)"},{"line_number":485,"context_line":"        print \u003e\u003e sys.stderr, strutils.safe_encode(error)"},{"line_number":486,"context_line":"        sys.exit(1)"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAAP3%2F%2Fldg%3D","line":484,"in_reply_to":"AAAAP3%2F%2FpQE%3D","updated":"2013-07-16 09:11:17.000000000","message":"ok, it took me to long to explain it. I\u0027ll change the logic. :D","commit_id":"635feb616e483aacc59cf18f73c697b052923572"},{"author":{"_account_id":1390,"name":"Paul Bourke","email":"pauldbourke@proton.me","username":"pauldbourke"},"change_message_id":"2a706c4d5a5f835711d690b39af73b25934ac993","unresolved":false,"context_lines":[{"line_number":478,"context_line":"            error \u003d unicode(e)"},{"line_number":479,"context_line":"        except UnicodeError:"},{"line_number":480,"context_line":"            try:"},{"line_number":481,"context_line":"                error \u003d str(e)"},{"line_number":482,"context_line":"            except UnicodeError:"},{"line_number":483,"context_line":"                error \u003d (\"Caught exception %(exception)s but \""},{"line_number":484,"context_line":"                         \"couldn\u0027t convert it to string. Re-raising\" %"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAP3%2F%2FjZA%3D","line":481,"updated":"2013-07-16 17:05:47.000000000","message":"Could you give an example of a case where the above call to unicode() would fail, but str() would not?\n\nI\u0027m still not quite seeing why all this code is needed (lines 475 - 491).  It seems the problem was print could not call repr() on e when it\u0027s message contained unicode.  So just calling strutils.safe_encode on e.message seems reasonable? (http://paste.openstack.org/show/40576/)","commit_id":"46787a5dbe35928055a7f3d0096630b06cfcba66"},{"author":{"_account_id":1390,"name":"Paul Bourke","email":"pauldbourke@proton.me","username":"pauldbourke"},"change_message_id":"a86c54ab5044a5db3b5413ba7e9b3206a1123faa","unresolved":false,"context_lines":[{"line_number":478,"context_line":"            error \u003d unicode(e)"},{"line_number":479,"context_line":"        except UnicodeError:"},{"line_number":480,"context_line":"            try:"},{"line_number":481,"context_line":"                error \u003d str(e)"},{"line_number":482,"context_line":"            except UnicodeError:"},{"line_number":483,"context_line":"                error \u003d (\"Caught exception %(exception)s but \""},{"line_number":484,"context_line":"                         \"couldn\u0027t convert it to string. Re-raising\" %"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAP3%2F%2Ff%2F8%3D","line":481,"in_reply_to":"AAAAP3%2F%2FiFs%3D","updated":"2013-07-17 10:25:29.000000000","message":"Good explanation Flavio, thanks.  I\u0027d be happy to +1 based on this; I think a test would go a long way to to spell it out for future inquirers though?\n\nI also asked Zhi Yan Liu to check in on this patch as he seems to have stumbled across the exact same issue in glance (https://review.openstack.org/#/c/37421/).","commit_id":"46787a5dbe35928055a7f3d0096630b06cfcba66"},{"author":{"_account_id":6159,"name":"Flavio Percoco Premoli","display_name":"flaper87","email":"flavio.percoco@flyrlabs.com","username":"flaper87"},"change_message_id":"8bd60cc50f4b5b022d60306ab9dab57bcb69ebdf","unresolved":false,"context_lines":[{"line_number":478,"context_line":"            error \u003d unicode(e)"},{"line_number":479,"context_line":"        except UnicodeError:"},{"line_number":480,"context_line":"            try:"},{"line_number":481,"context_line":"                error \u003d str(e)"},{"line_number":482,"context_line":"            except UnicodeError:"},{"line_number":483,"context_line":"                error \u003d (\"Caught exception %(exception)s but \""},{"line_number":484,"context_line":"                         \"couldn\u0027t convert it to string. Re-raising\" %"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAP3%2F%2FiFs%3D","line":481,"in_reply_to":"AAAAP3%2F%2FjZA%3D","updated":"2013-07-16 21:44:14.000000000","message":"Hey, \n\nThis is a case:\n\n    \u003e\u003e\u003e s \u003d \"\\xa5foo\"\n    \u003e\u003e\u003e unicode(s)\n    Traceback (most recent call last):\n      File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n    UnicodeDecodeError: \u0027ascii\u0027 codec can\u0027t decode byte 0xa5 in position 0: ordinal not in range(128)\n    \u003e\u003e\u003e str(s)\n    \u0027\\xa5foo\u0027\n    \u003e\u003e\u003e print s\n    ¥foo\n\nI\u0027m not using e.message because it\u0027s been deprecated in newer versions of python[0] so I prefer to call unicode (and hope for the exception to support it) and then call str if that fails. We could also do hasattr for messages and args but, this is an exception and we want to make sure it gets printed. So far, the previous code failed when non-ascii characters were to be printed and that hid the real exception.\n\n[0] http://www.python.org/dev/peps/pep-0352/","commit_id":"46787a5dbe35928055a7f3d0096630b06cfcba66"},{"author":{"_account_id":177,"name":"Alex Meade","email":"mr.alex.meade@gmail.com","username":"alex-meade"},"change_message_id":"e4fbbb5c275e091849c9bcfe8409968aa293586c","unresolved":false,"context_lines":[{"line_number":486,"context_line":""},{"line_number":487,"context_line":"                # NOTE(flaper87): Print message and"},{"line_number":488,"context_line":"                # re-raise the original exception, we"},{"line_number":489,"context_line":"                # don\u0027t want to loose valuable information."},{"line_number":490,"context_line":"                print \u003e\u003e sys.stderr, error"},{"line_number":491,"context_line":"                raise e"},{"line_number":492,"context_line":""}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAQn%2F%2Fvrw%3D","line":489,"updated":"2013-07-24 01:31:53.000000000","message":"little spelling nitpick, loose \u003d lose","commit_id":"46787a5dbe35928055a7f3d0096630b06cfcba66"},{"author":{"_account_id":6493,"name":"John Bresnahan","email":"john@bresnahan.me","username":"jbresnah"},"change_message_id":"c0a7d008cc330b6b46967ccdc082185e99aea8cd","unresolved":false,"context_lines":[{"line_number":488,"context_line":"                # re-raise the original exception, we"},{"line_number":489,"context_line":"                # don\u0027t want to loose valuable information."},{"line_number":490,"context_line":"                print \u003e\u003e sys.stderr, error"},{"line_number":491,"context_line":"                raise e"},{"line_number":492,"context_line":""},{"line_number":493,"context_line":"        # NOTE(flaper87): Ignore encoding errors, we want to get the"},{"line_number":494,"context_line":"        # real exception printed."}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAQn%2F%2FwJM%3D","line":491,"updated":"2013-07-23 21:32:31.000000000","message":"Could we make this into a common utility function?","commit_id":"46787a5dbe35928055a7f3d0096630b06cfcba66"},{"author":{"_account_id":177,"name":"Alex Meade","email":"mr.alex.meade@gmail.com","username":"alex-meade"},"change_message_id":"cdbb75a8420f524927356a76da29e3ddddc2582d","unresolved":false,"context_lines":[{"line_number":472,"context_line":"        print \u003e\u003e sys.stderr, \u0027... terminating glance client\u0027"},{"line_number":473,"context_line":"        sys.exit(1)"},{"line_number":474,"context_line":"    except Exception as e:"},{"line_number":475,"context_line":"        print \u003e\u003e sys.stderr, utils.exception_to_str(error)"},{"line_number":476,"context_line":"        sys.exit(1)"}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAQn%2F%2FmXw%3D","line":475,"updated":"2013-07-26 19:37:43.000000000","message":"should this argument be \u0027e\u0027 not \u0027error\u0027?","commit_id":"14e97206c964978d63b2335cd943b0911ea8d3b3"}]}
