)]}'
{"swiftclient/client.py":[{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"50af19d797a3196264afa8b27098bbd81abdce48","unresolved":false,"context_lines":[{"line_number":189,"context_line":"            for target_type in \u0027container\u0027, \u0027account\u0027, \u0027object\u0027:"},{"line_number":190,"context_line":"                prefix \u003d \u0027x-%s-meta-\u0027 % target_type"},{"line_number":191,"context_line":"                # Might be a bytes instance in Python 3"},{"line_number":192,"context_line":"                if isinstance(header, bytes):"},{"line_number":193,"context_line":"                    prefix \u003d prefix.encode()"},{"line_number":194,"context_line":"                if header.startswith(prefix):"},{"line_number":195,"context_line":"                    header \u003d encode_utf8(header)"}],"source_content_type":"text/x-python","patch_set":1,"id":"7adec928_b548dd2d","line":192,"updated":"2014-05-20 12:42:36.000000000","message":"On Python 2, calling prefix.encode() is useless because prefix type is already bytes (str in Python 2). You may write:\n\nif six.PY3 and isinstance(header, bytes):\n   prefix \u003d prefix.encode(\u0027utf-8\u0027)\n\nYou might move the test \"six.PY3 and isinstance(header, bytes)\" out of the inner loop.\n\nIs it possible that header type is unicode in Python 2? If yes, does the code still work?","commit_id":"8ec314576ff92f32e7972ebecdd1d8c75ee859d9"},{"author":{"_account_id":6968,"name":"Christian Schwede","email":"cschwede@nvidia.com","username":"cschwede"},"change_message_id":"d71f965dc0c228360db72c8d6c9d9b4d3725c8c6","unresolved":false,"context_lines":[{"line_number":189,"context_line":"            for target_type in \u0027container\u0027, \u0027account\u0027, \u0027object\u0027:"},{"line_number":190,"context_line":"                prefix \u003d \u0027x-%s-meta-\u0027 % target_type"},{"line_number":191,"context_line":"                # Might be a bytes instance in Python 3"},{"line_number":192,"context_line":"                if isinstance(header, bytes):"},{"line_number":193,"context_line":"                    prefix \u003d prefix.encode()"},{"line_number":194,"context_line":"                if header.startswith(prefix):"},{"line_number":195,"context_line":"                    header \u003d encode_utf8(header)"}],"source_content_type":"text/x-python","patch_set":1,"id":"7adec928_490e20e6","line":192,"in_reply_to":"7adec928_b548dd2d","updated":"2014-05-20 15:11:35.000000000","message":"OK, I\u0027ll add the six.PY3 condition to this.\nMoving the test out of the inner loop doesn\u0027t work well because header might be changed in the loop, thus I prefer to leave it at this place.\n\nCode works in Python2, even if the header is a unicode. I\u0027ll add a unittest for this.","commit_id":"8ec314576ff92f32e7972ebecdd1d8c75ee859d9"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"50af19d797a3196264afa8b27098bbd81abdce48","unresolved":false,"context_lines":[{"line_number":944,"context_line":"    if content_type is not None:"},{"line_number":945,"context_line":"        headers[\u0027Content-Type\u0027] \u003d content_type"},{"line_number":946,"context_line":"    else:  # python-requests sets application/x-www-form-urlencoded otherwise"},{"line_number":947,"context_line":"        headers[\u0027Content-Type\u0027] \u003d \u0027\u0027"},{"line_number":948,"context_line":"    if not contents:"},{"line_number":949,"context_line":"        headers[\u0027Content-Length\u0027] \u003d \u00270\u0027"},{"line_number":950,"context_line":"    if hasattr(contents, \u0027read\u0027):"}],"source_content_type":"text/x-python","patch_set":1,"id":"7adec928_b56ffd90","line":947,"updated":"2014-05-20 12:42:36.000000000","message":"Does Python send an HTTP header without value in this case?","commit_id":"8ec314576ff92f32e7972ebecdd1d8c75ee859d9"},{"author":{"_account_id":6968,"name":"Christian Schwede","email":"cschwede@nvidia.com","username":"cschwede"},"change_message_id":"d71f965dc0c228360db72c8d6c9d9b4d3725c8c6","unresolved":false,"context_lines":[{"line_number":944,"context_line":"    if content_type is not None:"},{"line_number":945,"context_line":"        headers[\u0027Content-Type\u0027] \u003d content_type"},{"line_number":946,"context_line":"    else:  # python-requests sets application/x-www-form-urlencoded otherwise"},{"line_number":947,"context_line":"        headers[\u0027Content-Type\u0027] \u003d \u0027\u0027"},{"line_number":948,"context_line":"    if not contents:"},{"line_number":949,"context_line":"        headers[\u0027Content-Length\u0027] \u003d \u00270\u0027"},{"line_number":950,"context_line":"    if hasattr(contents, \u0027read\u0027):"}],"source_content_type":"text/x-python","patch_set":1,"id":"7adec928_4925405a","line":947,"in_reply_to":"7adec928_b56ffd90","updated":"2014-05-20 15:11:35.000000000","message":"Yes, and in that case the swift proxy sets the content-type to \"application/octet-stream\" (and the functional tests are checking this).","commit_id":"8ec314576ff92f32e7972ebecdd1d8c75ee859d9"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"88d78d6256a1bddc2822ea95a5f2163661c6f473","unresolved":false,"context_lines":[{"line_number":192,"context_line":"                if six.PY3 and isinstance(header, bytes):"},{"line_number":193,"context_line":"                    prefix \u003d prefix.encode(\u0027utf-8\u0027)"},{"line_number":194,"context_line":"                if header.startswith(prefix):"},{"line_number":195,"context_line":"                    header \u003d encode_utf8(header)"},{"line_number":196,"context_line":"            ret[header] \u003d value"},{"line_number":197,"context_line":"        return ret"},{"line_number":198,"context_line":""}],"source_content_type":"text/x-python","patch_set":3,"id":"7adec928_c4e21201","line":195,"updated":"2014-05-20 16:49:25.000000000","message":"The purpose of this inner loop is to encode the header to UTF-8. I don\u0027t think that an header can match two different prefixes and so you may add a \"break\" here. (And then you might move \"six.PY3 and isinstance(header, bytes)\" out of the inner loop.)\n\nBy the way, this loop may be useless if header type is already bytes. What do you think?\n\nSimplified code:\n\nif isinstance(header, six.text_type):\n  for target_type in ...:\n    prefix \u003d ..\n    if six.PY3:\n       prefix \u003d prefix.encode(\u0027utf-8\u0027)\n    if header.startswith(prefix):\n       header \u003d encode.encode(\u0027utf-8\u0027)\n       break\n\n(encode_utf8(header) does nothing is header type is bytes.)","commit_id":"fa8aad631fea921f0b9cc68361506f77409d6bfd"},{"author":{"_account_id":6968,"name":"Christian Schwede","email":"cschwede@nvidia.com","username":"cschwede"},"change_message_id":"bebc7935f269bdf158695fcf49c4ce7f020f6815","unresolved":false,"context_lines":[{"line_number":192,"context_line":"                if six.PY3 and isinstance(header, bytes):"},{"line_number":193,"context_line":"                    prefix \u003d prefix.encode(\u0027utf-8\u0027)"},{"line_number":194,"context_line":"                if header.startswith(prefix):"},{"line_number":195,"context_line":"                    header \u003d encode_utf8(header)"},{"line_number":196,"context_line":"            ret[header] \u003d value"},{"line_number":197,"context_line":"        return ret"},{"line_number":198,"context_line":""}],"source_content_type":"text/x-python","patch_set":3,"id":"7adec928_b87a8923","line":195,"in_reply_to":"7adec928_c4e21201","updated":"2014-05-20 19:10:04.000000000","message":"Agreed to use break to avoid unnecessary iterations, good point.\n\nBut we still need to use\n\n if six.PY3 and isinstance(header, bytes):\n\nbecause otherwise the prefix would be encoded even for headers of type str() and the header.startswith fails again. I think in most cases headers will be of type six.text_type, so we could simply skip that if-condition. What do you think?","commit_id":"fa8aad631fea921f0b9cc68361506f77409d6bfd"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"ce495bd4007768b63cb21c86ba0dc3bbe854fdc7","unresolved":false,"context_lines":[{"line_number":189,"context_line":"            for target_type in \u0027container\u0027, \u0027account\u0027, \u0027object\u0027:"},{"line_number":190,"context_line":"                prefix \u003d \u0027x-%s-meta-\u0027 % target_type"},{"line_number":191,"context_line":"                # Might be a bytes instance in Python 3"},{"line_number":192,"context_line":"                if six.PY3 and isinstance(header, bytes):"},{"line_number":193,"context_line":"                    prefix \u003d prefix.encode(\u0027utf-8\u0027)"},{"line_number":194,"context_line":"                if header.startswith(prefix):"},{"line_number":195,"context_line":"                    header \u003d encode_utf8(header)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7adec928_41725e4a","line":192,"updated":"2014-05-21 09:19:01.000000000","message":"can you not just \u0027break\u0027 here? even if header does start with prefix, encode_utf8 will do nothing.\n\nOr, maybe this is where Victor was heading:\n\n            if isinstance(header, six.text_type):\n                for target_type in \u0027container\u0027, \u0027account\u0027, \u0027object\u0027:\n                    prefix \u003d \u0027x-%s-meta-\u0027 % target_type\n                    if header.startswith(prefix):\n                        header \u003d encode_utf8(header)\n                        break\n\nsix.text_type may be the common case, but this way you do the test once rather than maybe 3 times with:\n    if six.PY3 and isinstance(header, bytes)","commit_id":"3820c9f95cfd3d57c8f20212add8f0c8cdb7364d"},{"author":{"_account_id":6968,"name":"Christian Schwede","email":"cschwede@nvidia.com","username":"cschwede"},"change_message_id":"cfb5f580035ca1a43a362e7a22173cc04e0ddec2","unresolved":false,"context_lines":[{"line_number":189,"context_line":"            for target_type in \u0027container\u0027, \u0027account\u0027, \u0027object\u0027:"},{"line_number":190,"context_line":"                prefix \u003d \u0027x-%s-meta-\u0027 % target_type"},{"line_number":191,"context_line":"                # Might be a bytes instance in Python 3"},{"line_number":192,"context_line":"                if six.PY3 and isinstance(header, bytes):"},{"line_number":193,"context_line":"                    prefix \u003d prefix.encode(\u0027utf-8\u0027)"},{"line_number":194,"context_line":"                if header.startswith(prefix):"},{"line_number":195,"context_line":"                    header \u003d encode_utf8(header)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7adec928_09123c58","line":192,"in_reply_to":"7adec928_41725e4a","updated":"2014-05-21 10:36:25.000000000","message":"This! Nice idea, works as expected. I\u0027ll update the patch. Thanks Alistair!","commit_id":"3820c9f95cfd3d57c8f20212add8f0c8cdb7364d"}]}
