)]}'
{"cinder/api/openstack/wsgi.py":[{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"2a29e860ed8142f8c43ceb28be9aa6e718dcc4f7","unresolved":false,"context_lines":[{"line_number":1151,"context_line":"        if hasattr(response, \u0027headers\u0027):"},{"line_number":1152,"context_line":"            for hdr, val in response.headers.items():"},{"line_number":1153,"context_line":"                # Headers must be utf-8 strings"},{"line_number":1154,"context_line":"                response.headers[hdr] \u003d encodeutils.safe_encode("},{"line_number":1155,"context_line":"                    val, incoming\u003d\u0027utf-8\u0027)"},{"line_number":1156,"context_line":""},{"line_number":1157,"context_line":"            if not request.api_version_request.is_null():"}],"source_content_type":"text/x-python","patch_set":1,"id":"7af24918_5a838198","line":1154,"range":{"start_line":1154,"start_character":40,"end_line":1154,"end_character":51},"updated":"2016-03-02 14:49:07.000000000","message":"This new code looks wrong to me.\n\nIn my experience, HTTP headers must be stored as bytes on Python 2, httplib is unable to encode them correctly (we want UTF-8).\n\nOn Python 3, HTTP headers must *not* be encoded but stored as Unicode. httplib is able to encode them. But I don\u0027t recall if they are encoded to Latin1 or UTF-8 :-/ This part of the HTTP protocol is quite of unclear to me.\n\nThe old code also looks wrong to me. try/except to support Python 3 doesn\u0027t look like a good design :-(\n\nI suggest something like:\n\nif six.PY2:\n    val \u003d encodeutils.to_utf8(val)\nelse:\n    if isinstance(val, bytes):\n        val \u003d val.decode(\u0027utf-8\u0027)\n    else:\n        val \u003d six.text_text(val)\n\nSorry, I don\u0027t understand which kinds of val can be get here. Only bytes or text (py2: unicode, py3: str)? Or also int? Maybe we also need to cast val to a string with str(val) in the Python 2 path?","commit_id":"111bb4a586a524307c85c97e735f8c2e8cbca0b3"},{"author":{"_account_id":7173,"name":"Scott DAngelo","email":"scott.dangelo@gmail.com","username":"scottda"},"change_message_id":"4cf46288fb92aff2c5ffb0eb07341037472cb9f4","unresolved":false,"context_lines":[{"line_number":1151,"context_line":"        if hasattr(response, \u0027headers\u0027):"},{"line_number":1152,"context_line":"            for hdr, val in response.headers.items():"},{"line_number":1153,"context_line":"                # Headers must be utf-8 strings"},{"line_number":1154,"context_line":"                response.headers[hdr] \u003d encodeutils.safe_encode("},{"line_number":1155,"context_line":"                    val, incoming\u003d\u0027utf-8\u0027)"},{"line_number":1156,"context_line":""},{"line_number":1157,"context_line":"            if not request.api_version_request.is_null():"}],"source_content_type":"text/x-python","patch_set":1,"id":"7af24918_7cd587b7","line":1154,"range":{"start_line":1154,"start_character":40,"end_line":1154,"end_character":51},"in_reply_to":"7af24918_5a838198","updated":"2016-03-02 18:09:07.000000000","message":"Thanks for looking at this. I\u0027m hoping your expertise in this area can help to get to a good solution.\nThe old code (which was just merged in with the patch for api-microversions) is quite hacky. I just didn\u0027t find a better path. I\u0027d like to replace this with something better and proper, but I\u0027m a bit hesitant to change this so late in the release cycle.\n\nDo you see anything Critical that needs fixing in the old code? Or is it just that it is a bad hack?","commit_id":"111bb4a586a524307c85c97e735f8c2e8cbca0b3"},{"author":{"_account_id":1207,"name":"Duncan Thomas","email":"duncan.thomas@gmail.com","username":"duncan-thomas"},"change_message_id":"0fb4609473262a42dba54ea702cf63e81ddd71b7","unresolved":false,"context_lines":[{"line_number":1157,"context_line":"                    if isinstance(val, bytes):"},{"line_number":1158,"context_line":"                        response.headers[hdr] \u003d val.decode(\u0027utf-8\u0027)"},{"line_number":1159,"context_line":"                    else:"},{"line_number":1160,"context_line":"                        response.headers[hdr] \u003d six.text_text(val)"},{"line_number":1161,"context_line":""},{"line_number":1162,"context_line":"            if not request.api_version_request.is_null():"},{"line_number":1163,"context_line":"                response.headers[API_VERSION_REQUEST_HEADER] \u003d ("}],"source_content_type":"text/x-python","patch_set":2,"id":"ba0121b8_b58f5acb","line":1160,"range":{"start_line":1160,"start_character":52,"end_line":1160,"end_character":61},"updated":"2016-03-29 19:15:55.000000000","message":"you almost certainly mean text_type here....","commit_id":"0d4d17d522995ec6cc6c7d228c6d2e8fd45fc9b8"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"d8510af5a5ee3bf8c4653d7fb02dcbbbe2bc04e3","unresolved":false,"context_lines":[{"line_number":1152,"context_line":"            for hdr, val in response.headers.items():"},{"line_number":1153,"context_line":"                # Headers must be utf-8 strings"},{"line_number":1154,"context_line":"                if six.PY2:"},{"line_number":1155,"context_line":"                    response.headers[hdr] \u003d encodeutils.to_utf8(val)"},{"line_number":1156,"context_line":"                else:"},{"line_number":1157,"context_line":"                    if isinstance(val, bytes):"},{"line_number":1158,"context_line":"                        response.headers[hdr] \u003d val.decode(\u0027utf-8\u0027)"}],"source_content_type":"text/x-python","patch_set":3,"id":"ba0121b8_2a4e486f","line":1155,"updated":"2016-03-29 19:46:51.000000000","message":"You should store the result in val, and only have one final line to write val into response.headers[hdr] (instead of repeating response.headers[hdr] \u003d ....).","commit_id":"ed66717f09c5f21c91f5fa3a3a4ff77ab1ae607d"},{"author":{"_account_id":7173,"name":"Scott DAngelo","email":"scott.dangelo@gmail.com","username":"scottda"},"change_message_id":"389ff1a9ca14737464200c6d2166df9ff62df616","unresolved":false,"context_lines":[{"line_number":1152,"context_line":"            for hdr, val in response.headers.items():"},{"line_number":1153,"context_line":"                # Headers must be utf-8 strings"},{"line_number":1154,"context_line":"                if six.PY2:"},{"line_number":1155,"context_line":"                    response.headers[hdr] \u003d encodeutils.to_utf8(val)"},{"line_number":1156,"context_line":"                else:"},{"line_number":1157,"context_line":"                    if isinstance(val, bytes):"},{"line_number":1158,"context_line":"                        response.headers[hdr] \u003d val.decode(\u0027utf-8\u0027)"}],"source_content_type":"text/x-python","patch_set":3,"id":"ba0121b8_c08ccb81","line":1155,"in_reply_to":"ba0121b8_2a4e486f","updated":"2016-03-29 20:28:45.000000000","message":"Thanks, will do.","commit_id":"ed66717f09c5f21c91f5fa3a3a4ff77ab1ae607d"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"d8510af5a5ee3bf8c4653d7fb02dcbbbe2bc04e3","unresolved":false,"context_lines":[{"line_number":1157,"context_line":"                    if isinstance(val, bytes):"},{"line_number":1158,"context_line":"                        response.headers[hdr] \u003d val.decode(\u0027utf-8\u0027)"},{"line_number":1159,"context_line":"                    else:"},{"line_number":1160,"context_line":"                        response.headers[hdr] \u003d six.text_type(val)"},{"line_number":1161,"context_line":""},{"line_number":1162,"context_line":"            if not request.api_version_request.is_null():"},{"line_number":1163,"context_line":"                response.headers[API_VERSION_REQUEST_HEADER] \u003d ("}],"source_content_type":"text/x-python","patch_set":3,"id":"ba0121b8_aa3b78d0","line":1160,"range":{"start_line":1160,"start_character":33,"end_line":1160,"end_character":40},"updated":"2016-03-29 19:46:51.000000000","message":"Since you know that this code is specific to py3, you may replace six.text_type(val) with str(val).","commit_id":"ed66717f09c5f21c91f5fa3a3a4ff77ab1ae607d"},{"author":{"_account_id":7173,"name":"Scott DAngelo","email":"scott.dangelo@gmail.com","username":"scottda"},"change_message_id":"389ff1a9ca14737464200c6d2166df9ff62df616","unresolved":false,"context_lines":[{"line_number":1157,"context_line":"                    if isinstance(val, bytes):"},{"line_number":1158,"context_line":"                        response.headers[hdr] \u003d val.decode(\u0027utf-8\u0027)"},{"line_number":1159,"context_line":"                    else:"},{"line_number":1160,"context_line":"                        response.headers[hdr] \u003d six.text_type(val)"},{"line_number":1161,"context_line":""},{"line_number":1162,"context_line":"            if not request.api_version_request.is_null():"},{"line_number":1163,"context_line":"                response.headers[API_VERSION_REQUEST_HEADER] \u003d ("}],"source_content_type":"text/x-python","patch_set":3,"id":"ba0121b8_00ed2325","line":1160,"range":{"start_line":1160,"start_character":33,"end_line":1160,"end_character":40},"in_reply_to":"ba0121b8_aa3b78d0","updated":"2016-03-29 20:28:45.000000000","message":"OK, will do.","commit_id":"ed66717f09c5f21c91f5fa3a3a4ff77ab1ae607d"}]}
