)]}'
{"jenkins/__init__.py":[{"author":{"_account_id":6987,"name":"Khai Do","email":"zaro0508@gmail.com","username":"zaro0508"},"change_message_id":"4404d870a21a7b8122ebe2a09a5501ac9d047f2f","unresolved":false,"context_lines":[{"line_number":163,"context_line":""},{"line_number":164,"context_line":"    def __init__(self, url, username\u003dNone, password\u003dNone,"},{"line_number":165,"context_line":"                 timeout \u003d socket._GLOBAL_DEFAULT_TIMEOUT,"},{"line_number":166,"context_line":"                 err_handle \u003d \u0027strict\u0027):"},{"line_number":167,"context_line":"        \u0027\u0027\u0027Create handle to Jenkins instance."},{"line_number":168,"context_line":""},{"line_number":169,"context_line":"        All methods will raise :class:`JenkinsException` on failure."}],"source_content_type":"text/x-python","patch_set":1,"id":"9a41bdd9_84a028a7","line":166,"updated":"2015-07-17 05:11:21.000000000","message":"pep8 test does not like the spaces around the \u0027\u003d\u0027.  please remove spaces.","commit_id":"7e19f5b4e97ed539c0dd12c1e973953e5a6e8fbd"},{"author":{"_account_id":6987,"name":"Khai Do","email":"zaro0508@gmail.com","username":"zaro0508"},"change_message_id":"4404d870a21a7b8122ebe2a09a5501ac9d047f2f","unresolved":false,"context_lines":[{"line_number":172,"context_line":"        :param password: Server password, ``str``"},{"line_number":173,"context_line":"        :param url: URL of Jenkins server, ``str``"},{"line_number":174,"context_line":"        :param timeout: Server connection timeout in secs (default: not set), ``int``"},{"line_number":175,"context_line":"        :param err_handke: the error handling method to decode the response (default strict,can be ignore or replace) ``str``"},{"line_number":176,"context_line":"        \u0027\u0027\u0027"},{"line_number":177,"context_line":"        if url[-1] \u003d\u003d \u0027/\u0027:"},{"line_number":178,"context_line":"            self.server \u003d url"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a41bdd9_047c181f","line":175,"updated":"2015-07-17 05:11:21.000000000","message":"would you mind making these less than 80 chars?","commit_id":"7e19f5b4e97ed539c0dd12c1e973953e5a6e8fbd"},{"author":{"_account_id":6987,"name":"Khai Do","email":"zaro0508@gmail.com","username":"zaro0508"},"change_message_id":"eff1d48cd693dffffb79d6b9c5165778d362e308","unresolved":false,"context_lines":[{"line_number":184,"context_line":"            self.auth \u003d None"},{"line_number":185,"context_line":"        self.crumb \u003d None"},{"line_number":186,"context_line":"        self.timeout \u003d timeout"},{"line_number":187,"context_line":"        self.err_handle \u003d err_handle"},{"line_number":188,"context_line":""},{"line_number":189,"context_line":"    def _get_encoded_params(self, params):"},{"line_number":190,"context_line":"        for k, v in params.items():"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa32b979_6c3b7d39","line":187,"updated":"2015-06-26 17:02:10.000000000","message":"would be nice to verify that the user passed in a valid err_handle.","commit_id":"7e19f5b4e97ed539c0dd12c1e973953e5a6e8fbd"},{"author":{"_account_id":6987,"name":"Khai Do","email":"zaro0508@gmail.com","username":"zaro0508"},"change_message_id":"4404d870a21a7b8122ebe2a09a5501ac9d047f2f","unresolved":false,"context_lines":[{"line_number":184,"context_line":"            self.auth \u003d None"},{"line_number":185,"context_line":"        self.crumb \u003d None"},{"line_number":186,"context_line":"        self.timeout \u003d timeout"},{"line_number":187,"context_line":"        self.err_handle \u003d err_handle"},{"line_number":188,"context_line":""},{"line_number":189,"context_line":"    def _get_encoded_params(self, params):"},{"line_number":190,"context_line":"        for k, v in params.items():"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a41bdd9_44dc6046","line":187,"in_reply_to":"fa32b979_28e461aa","updated":"2015-07-17 05:11:21.000000000","message":"ok. thanks for the explanation.","commit_id":"7e19f5b4e97ed539c0dd12c1e973953e5a6e8fbd"},{"author":{"_account_id":16889,"name":"rafi wiener","email":"rafiwiener@gmail.com","username":"rafiw"},"change_message_id":"79f08bf17ef80592f08f684271e84271b5da2954","unresolved":false,"context_lines":[{"line_number":184,"context_line":"            self.auth \u003d None"},{"line_number":185,"context_line":"        self.crumb \u003d None"},{"line_number":186,"context_line":"        self.timeout \u003d timeout"},{"line_number":187,"context_line":"        self.err_handle \u003d err_handle"},{"line_number":188,"context_line":""},{"line_number":189,"context_line":"    def _get_encoded_params(self, params):"},{"line_number":190,"context_line":"        for k, v in params.items():"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa32b979_28e461aa","line":187,"in_reply_to":"fa32b979_6c3b7d39","updated":"2015-06-28 13:24:18.000000000","message":"i think not\nfirst of all there is a pydoc for this in the class doc that says the legal option\nsecond of all giving a bad parameter will raise an exception from the inner module as you can try for yourself\n\u003e\u003e\u003e encodings.utf_8.decode(\u0027\\x00\\x00\\xfe\\xff\u0027,\u0027fsdf\u0027)\nTraceback (most recent call last):\n  File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n  File \"/usr/lib64/python2.6/encodings/utf_8.py\", line 16, in decode\n    return codecs.utf_8_decode(input, errors, True)\nLookupError: unknown error handler name \u0027fsdf\u0027\n\nthird even if i will do a validation, it will be bad because if in the future codecs will support more keywords i will have to change my validation and there will be more code to maintain.\nfinally i can add another except around the decode catching LookupError but i\u0027m against it because translating the exception to another one will just cause confusion and  will make it hard to find the real bug in google\\stackoverflow etc.","commit_id":"7e19f5b4e97ed539c0dd12c1e973953e5a6e8fbd"},{"author":{"_account_id":1054,"name":"Darragh Bailey","email":"daragh.bailey@gmail.com","username":"dbailey-k"},"change_message_id":"5a5953a592ea22aa65c77ee4ab73038be85dcf98","unresolved":false,"context_lines":[{"line_number":196,"context_line":""},{"line_number":197,"context_line":"    def __init__(self, url, username\u003dNone, password\u003dNone,"},{"line_number":198,"context_line":"                 timeout\u003dsocket._GLOBAL_DEFAULT_TIMEOUT,"},{"line_number":199,"context_line":"                 err_handle\u003d\u0027strict\u0027):"},{"line_number":200,"context_line":"        \u0027\u0027\u0027Create handle to Jenkins instance."},{"line_number":201,"context_line":""},{"line_number":202,"context_line":"        All methods will raise :class:`JenkinsException` on failure."}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_27b035dd","line":199,"updated":"2015-07-20 14:27:52.000000000","message":"I\u0027m a little concerned that err_handle is somewhat misleading. What about a custom err_handler for other errors that occur, such as providing a callback to provide handling for other errors.\n\nI would suggest something that identifies this as response decoding at least.\n\nRather than trying to hack various options in to allow changing how we handle different error scenarios, perhaps a setting to control whether we return the raw response object instead of the response it self would be a solution here?","commit_id":"b8c3100c15d26eaf4df4608911b9156a3f98cec7"},{"author":{"_account_id":16889,"name":"rafi wiener","email":"rafiwiener@gmail.com","username":"rafiw"},"change_message_id":"10e51bcff1942275369770c4744a8b529957402a","unresolved":false,"context_lines":[{"line_number":196,"context_line":""},{"line_number":197,"context_line":"    def __init__(self, url, username\u003dNone, password\u003dNone,"},{"line_number":198,"context_line":"                 timeout\u003dsocket._GLOBAL_DEFAULT_TIMEOUT,"},{"line_number":199,"context_line":"                 err_handle\u003d\u0027strict\u0027):"},{"line_number":200,"context_line":"        \u0027\u0027\u0027Create handle to Jenkins instance."},{"line_number":201,"context_line":""},{"line_number":202,"context_line":"        All methods will raise :class:`JenkinsException` on failure."}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_9d4958d3","line":199,"in_reply_to":"3a50d1a3_27b035dd","updated":"2015-07-20 14:49:38.000000000","message":"first understand the issue then you can offer a different name for this variable","commit_id":"b8c3100c15d26eaf4df4608911b9156a3f98cec7"},{"author":{"_account_id":1054,"name":"Darragh Bailey","email":"daragh.bailey@gmail.com","username":"dbailey-k"},"change_message_id":"5a5953a592ea22aa65c77ee4ab73038be85dcf98","unresolved":false,"context_lines":[{"line_number":205,"context_line":"        :param password: Server password, ``str``"},{"line_number":206,"context_line":"        :param url: URL of Jenkins server, ``str``"},{"line_number":207,"context_line":"        :param timeout: Server connection timeout in secs (default: not set), ``int``"},{"line_number":208,"context_line":"        :param err_handle: the error handling method to decode the response \\"},{"line_number":209,"context_line":"                           (default strict,can be ignore or replace) ``str``"},{"line_number":210,"context_line":"        \u0027\u0027\u0027"},{"line_number":211,"context_line":"        if url[-1] \u003d\u003d \u0027/\u0027:"}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_871d8975","line":208,"updated":"2015-07-20 14:27:52.000000000","message":"trailing slash is not needed, just indent the following line by 4 spaces from the start of the preceding line and sphinx will handle the continuation just fine.","commit_id":"b8c3100c15d26eaf4df4608911b9156a3f98cec7"},{"author":{"_account_id":16889,"name":"rafi wiener","email":"rafiwiener@gmail.com","username":"rafiw"},"change_message_id":"10e51bcff1942275369770c4744a8b529957402a","unresolved":false,"context_lines":[{"line_number":205,"context_line":"        :param password: Server password, ``str``"},{"line_number":206,"context_line":"        :param url: URL of Jenkins server, ``str``"},{"line_number":207,"context_line":"        :param timeout: Server connection timeout in secs (default: not set), ``int``"},{"line_number":208,"context_line":"        :param err_handle: the error handling method to decode the response \\"},{"line_number":209,"context_line":"                           (default strict,can be ignore or replace) ``str``"},{"line_number":210,"context_line":"        \u0027\u0027\u0027"},{"line_number":211,"context_line":"        if url[-1] \u003d\u003d \u0027/\u0027:"}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_1dfea86b","line":208,"in_reply_to":"3a50d1a3_871d8975","updated":"2015-07-20 14:49:38.000000000","message":"ok first finish other remarks","commit_id":"b8c3100c15d26eaf4df4608911b9156a3f98cec7"},{"author":{"_account_id":1054,"name":"Darragh Bailey","email":"daragh.bailey@gmail.com","username":"dbailey-k"},"change_message_id":"5a5953a592ea22aa65c77ee4ab73038be85dcf98","unresolved":false,"context_lines":[{"line_number":319,"context_line":"                raise EmptyResponseException("},{"line_number":320,"context_line":"                    \"Error communicating with server[%s]: \""},{"line_number":321,"context_line":"                    \"empty response\" % self.server)"},{"line_number":322,"context_line":"            return response.decode(\u0027utf-8\u0027, self.err_handle)"},{"line_number":323,"context_line":"        except HTTPError as e:"},{"line_number":324,"context_line":"            # Jenkins\u0027s funky authentication means its nigh impossible to"},{"line_number":325,"context_line":"            # distinguish errors."}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_c74631bf","line":322,"updated":"2015-07-20 14:27:52.000000000","message":"What is the problem that you\u0027re running into with the strict decoding? Can you simulate this with a basic test.","commit_id":"b8c3100c15d26eaf4df4608911b9156a3f98cec7"},{"author":{"_account_id":1054,"name":"Darragh Bailey","email":"daragh.bailey@gmail.com","username":"dbailey-k"},"change_message_id":"758bb382e4ca21b415477624dfc9979d7de25455","unresolved":false,"context_lines":[{"line_number":319,"context_line":"                raise EmptyResponseException("},{"line_number":320,"context_line":"                    \"Error communicating with server[%s]: \""},{"line_number":321,"context_line":"                    \"empty response\" % self.server)"},{"line_number":322,"context_line":"            return response.decode(\u0027utf-8\u0027, self.err_handle)"},{"line_number":323,"context_line":"        except HTTPError as e:"},{"line_number":324,"context_line":"            # Jenkins\u0027s funky authentication means its nigh impossible to"},{"line_number":325,"context_line":"            # distinguish errors."}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_a75d16eb","line":322,"in_reply_to":"3a50d1a3_7de24cd7","updated":"2015-07-20 18:29:06.000000000","message":"Ok, to be more specific:\n\nWhat response are you getting from a Jenkins server that triggers this?\n\nCan always provide garbage to trigger an error somewhere, but that doesn\u0027t actually identify in what scenarios would a response back from Jenkins not be utf-8 encoded.","commit_id":"b8c3100c15d26eaf4df4608911b9156a3f98cec7"},{"author":{"_account_id":16889,"name":"rafi wiener","email":"rafiwiener@gmail.com","username":"rafiw"},"change_message_id":"05c43e49871a17fddf68096620b5e8547ef546b7","unresolved":false,"context_lines":[{"line_number":319,"context_line":"                raise EmptyResponseException("},{"line_number":320,"context_line":"                    \"Error communicating with server[%s]: \""},{"line_number":321,"context_line":"                    \"empty response\" % self.server)"},{"line_number":322,"context_line":"            return response.decode(\u0027utf-8\u0027, self.err_handle)"},{"line_number":323,"context_line":"        except HTTPError as e:"},{"line_number":324,"context_line":"            # Jenkins\u0027s funky authentication means its nigh impossible to"},{"line_number":325,"context_line":"            # distinguish errors."}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_8cca656d","line":322,"in_reply_to":"3a50d1a3_837d60b3","updated":"2015-07-21 07:53:42.000000000","message":"i have no idea what is the char-set of the response and how to check it, if you will explain how i can check this.\nbut i do know that the assumption that jenkins returns utf8 is wrong and causes errors.","commit_id":"b8c3100c15d26eaf4df4608911b9156a3f98cec7"},{"author":{"_account_id":1054,"name":"Darragh Bailey","email":"daragh.bailey@gmail.com","username":"dbailey-k"},"change_message_id":"5b8ffa91c438121979cf0f9aacac42ed427da1b0","unresolved":false,"context_lines":[{"line_number":319,"context_line":"                raise EmptyResponseException("},{"line_number":320,"context_line":"                    \"Error communicating with server[%s]: \""},{"line_number":321,"context_line":"                    \"empty response\" % self.server)"},{"line_number":322,"context_line":"            return response.decode(\u0027utf-8\u0027, self.err_handle)"},{"line_number":323,"context_line":"        except HTTPError as e:"},{"line_number":324,"context_line":"            # Jenkins\u0027s funky authentication means its nigh impossible to"},{"line_number":325,"context_line":"            # distinguish errors."}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_32fd9b3a","line":322,"in_reply_to":"3a50d1a3_8cca656d","updated":"2015-07-21 14:05:07.000000000","message":"So a few lines above where we call:\n\n    response \u003d urlopen(req, timeout\u003dself.timeout).read()\n\nWe should probably really drop the .read() call and hold onto the response object returned by urlopen by using:\n\n    response \u003d urlopen(req, timeout\u003dself.timeout)\n    contents \u003d response.read()\n    if contents is None:\n        ....\n\nThe response object then in this case is like a file object, but also contains the methods info(), getcode() and geturl() to retrieve addition information.\n\nSee https://docs.python.org/2/library/urllib.html#high-level-interface for details. Basically the info() method returns an instance of mimetools.Message that can be queried using gettype() to determine the content type which will return \u0027text/plain\u0027 if none is defined. We should probably check this to ensure it starts with \u0027text/\u0027 before attempting to read the contents, and also before attempting to decode anything. i.e.\n\n    if response.info().getmaintype() \u003d\u003d \u0027text\u0027:\n        # only read and decode text data\n\nAdditionally the mimetools.Message has a method getplist() (https://docs.python.org/2/library/mimetools.html#mimetools.Message.getplist) which will return everything in the header \u0027Content-Type: text/plain; \u003cextra data\u003e\u0027 listed in \"\u003cextra data\u003e\" which is exactly where the charset would be defined.\n\nI would expect we should be getting the following header from Jenkins:\n\n    Content-Type:text/xml; charset\u003dutf-8\n\nReading the documentation on https://docs.python.org/2/library/mimetools.html#module-mimetools suggests that the following should be used to extract the expected charset:\n\n        charset \u003d response.info().getparam(\u0027charset\u0027)\n        return contents.decode(charset)\n\n\nPutting this altogether:\n\n    response \u003d urlopen(req, timeout\u003dself.timeout)\n    mimedata \u003d response.info()\n    if mimedata.getmaintype() \u003d\u003d \u0027text\u0027:\n        # only read and decode text data\n        contents \u003d response.read()\n        # provide a default of utf-8 if it\u0027s missing\n        charset \u003d mimedata.getparam(\u0027charset\u0027) or \u0027utf-8\u0027\n        return contents.decode(charset)\n    else:\n        # return the raw contents, though this may not be a good idea\n        # with a long stream of data\n        return response.read()\n\n\nHowever as you\u0027ve stated this is still a little limited, so I would suggest placing from \u0027mimedata \u003d response.info()\u0027 downwards into a _response_handler method on the object, and have the init function take a custom response_handler callback to use instead of the default.\n\nThis would allow for situations where we cannot predict how people will use the API calls to customize how the response is handled to their application usage.\n\nUnfortunately digging through the documentation suggests that the above won\u0027t work on python 3, so it looks as though we probably also need to switch to using the requests library to be able to handle various responses.\n\nIt would be still be a useful information point if you can patch locally with the above suggestion to establish whether the idea works in your case. At the very least that may allow you to add some print statements to dump out information about what headers are defined and the charset detected.\n\nI will look at converting the library to use \"requests\" instead, which will probably clean up a few things and provide a generic python 2/3 version of a response_handler and then this change could be co-opted to add support for a custom response_handler to be registered through the constructor.","commit_id":"b8c3100c15d26eaf4df4608911b9156a3f98cec7"},{"author":{"_account_id":16889,"name":"rafi wiener","email":"rafiwiener@gmail.com","username":"rafiw"},"change_message_id":"c579d427b9b0227e47a2de0583695cdbf506121f","unresolved":false,"context_lines":[{"line_number":319,"context_line":"                raise EmptyResponseException("},{"line_number":320,"context_line":"                    \"Error communicating with server[%s]: \""},{"line_number":321,"context_line":"                    \"empty response\" % self.server)"},{"line_number":322,"context_line":"            return response.decode(\u0027utf-8\u0027, self.err_handle)"},{"line_number":323,"context_line":"        except HTTPError as e:"},{"line_number":324,"context_line":"            # Jenkins\u0027s funky authentication means its nigh impossible to"},{"line_number":325,"context_line":"            # distinguish errors."}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_a75f5671","line":322,"in_reply_to":"3a50d1a3_a75d16eb","updated":"2015-07-20 18:38:20.000000000","message":"i\u0027m running a very long script that compiles lots of stuff, this exception happens when i\u0027m trying to get the output.\nyou can blame the script but still this module is not flexible enough","commit_id":"b8c3100c15d26eaf4df4608911b9156a3f98cec7"},{"author":{"_account_id":1054,"name":"Darragh Bailey","email":"daragh.bailey@gmail.com","username":"dbailey-k"},"change_message_id":"40424fb0078d09f57980cc38fea05f0908a4fbd8","unresolved":false,"context_lines":[{"line_number":319,"context_line":"                raise EmptyResponseException("},{"line_number":320,"context_line":"                    \"Error communicating with server[%s]: \""},{"line_number":321,"context_line":"                    \"empty response\" % self.server)"},{"line_number":322,"context_line":"            return response.decode(\u0027utf-8\u0027, self.err_handle)"},{"line_number":323,"context_line":"        except HTTPError as e:"},{"line_number":324,"context_line":"            # Jenkins\u0027s funky authentication means its nigh impossible to"},{"line_number":325,"context_line":"            # distinguish errors."}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_837d60b3","line":322,"in_reply_to":"3a50d1a3_a75f5671","updated":"2015-07-21 00:53:53.000000000","message":"Is there anyway to debug the raw response due to that script?\n\nI suspect the underlying problem is that we are decoding a response that is not in utf-8 and has a different charset specified in the headers. So if instead of just assuming utf-8, we decoded the response based on what we\u0027re told to use to decode (provided we check that the return type is actually text), it would work as expected.\n\nOther than that, I would be looking to change the code to register a custom response handler that is called each time, where the default is to decode the response using the charset from the headers.\n\nBut allowing to ignore the errors means that we are returning a potentially corrupted response instead, with no way for the caller to get the original response to do anything with it. That potentially renders the response worthless and at the same time adds another option to the API that must be supported in the future.\n\n\nIf we can\u0027t decode the response correctly, then we need to find a way to allow the caller to handle the response instead rather than trashing it and returning garbage.","commit_id":"b8c3100c15d26eaf4df4608911b9156a3f98cec7"},{"author":{"_account_id":16889,"name":"rafi wiener","email":"rafiwiener@gmail.com","username":"rafiw"},"change_message_id":"10e51bcff1942275369770c4744a8b529957402a","unresolved":false,"context_lines":[{"line_number":319,"context_line":"                raise EmptyResponseException("},{"line_number":320,"context_line":"                    \"Error communicating with server[%s]: \""},{"line_number":321,"context_line":"                    \"empty response\" % self.server)"},{"line_number":322,"context_line":"            return response.decode(\u0027utf-8\u0027, self.err_handle)"},{"line_number":323,"context_line":"        except HTTPError as e:"},{"line_number":324,"context_line":"            # Jenkins\u0027s funky authentication means its nigh impossible to"},{"line_number":325,"context_line":"            # distinguish errors."}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_7de24cd7","line":322,"in_reply_to":"3a50d1a3_c74631bf","updated":"2015-07-20 14:49:38.000000000","message":"\u003e\u003e\u003e encodings.codecs.utf_8_decode(\u0027\\x00\\x00\\xfe\\xff\u0027)\nTraceback (most recent call last):\n  File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\nUnicodeDecodeError: \u0027utf8\u0027 codec can\u0027t decode byte 0xfe in position 2: invalid start byte\n\u003e\u003e\u003e encodings.codecs.utf_8_decode(\u0027\\x00\\x00\\xfe\\xff\u0027,\u0027ignore\u0027)\n(u\u0027\\x00\\x00\u0027, 4)","commit_id":"b8c3100c15d26eaf4df4608911b9156a3f98cec7"}]}
