)]}'
{"novaclient/v2/shell.py":[{"author":{"_account_id":679,"name":"Kevin L. Mitchell","email":"klmitch@mit.edu","username":"klmitch"},"change_message_id":"0b7cada842d1e73e420bf4b75e670e59f3c7841a","unresolved":false,"context_lines":[{"line_number":2596,"context_line":"    server \u003d _find_server(cs, args.server)"},{"line_number":2597,"context_line":"    data \u003d server.get_console_output(length\u003dargs.length)"},{"line_number":2598,"context_line":"    sys.stdout \u003d codecs.getwriter(\u0027utf8\u0027)(sys.stdout)"},{"line_number":2599,"context_line":"    sys.stdout.write(data)"},{"line_number":2600,"context_line":""},{"line_number":2601,"context_line":""},{"line_number":2602,"context_line":"@utils.arg(\u0027server\u0027, metavar\u003d\u0027\u003cserver\u003e\u0027, help\u003d_(\u0027Name or ID of server.\u0027))"}],"source_content_type":"text/x-python","patch_set":2,"id":"3fa0c359_801dc474","line":2599,"updated":"2018-02-07 16:14:13.000000000","message":"This makes sense to me, but I have two quibbles:\n\n1. I\u0027d prefer we not replace sys.stdout, even in a function that is soon going to exit.  After all, the test suite calls this function to test its action (or it should…)\n\n2. The print() built-in in Python appends a newline to the output, while the .write() method does not.\n\nLet me suggest this alteration instead:\n\n    if data and data[-1] !\u003d \u0027\\n\u0027:\n        data +\u003d \u0027\\n\u0027\n    codecs.getwriter(\u0027utf-8\u0027)(sys.stdout).write(data)\n\nThe first two lines add newlines, and the last line eliminates the reassignment of sys.stdout, as well as calling write within the same line of code.  (Some may argue that that\u0027s too obfuscated, and I\u0027d be fine with assigning the output of codecs.getwriter(\u0027utf-8\u0027)(sys.stdout) to an intermediate variable, then calling .write(); I just don\u0027t want that intermediate variable to be sys.stdout!)","commit_id":"be876fb3cc64717b6dea64e2f6f7f84c27f95aec"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"ea583979e21c48e0f7fc536fad51b64e21f35f19","unresolved":false,"context_lines":[{"line_number":2598,"context_line":""},{"line_number":2599,"context_line":"    if data and data[-1] !\u003d \u0027\\n\u0027:"},{"line_number":2600,"context_line":"        data +\u003d \u0027\\n\u0027"},{"line_number":2601,"context_line":"    codecs.getwriter(\u0027utf-8\u0027)(sys.stdout).write(data)"},{"line_number":2602,"context_line":""},{"line_number":2603,"context_line":""},{"line_number":2604,"context_line":"@utils.arg(\u0027server\u0027, metavar\u003d\u0027\u003cserver\u003e\u0027, help\u003d_(\u0027Name or ID of server.\u0027))"}],"source_content_type":"text/x-python","patch_set":3,"id":"5fc1f717_b6b9f779","line":2601,"range":{"start_line":2601,"start_character":0,"end_line":2601,"end_character":53},"updated":"2019-04-05 06:40:36.000000000","message":"Spotted way after the fact, this fails on Python 3:\n\n  \u003e\u003e\u003e import codecs\n  \u003e\u003e\u003e import sys\n  \u003e\u003e\u003e codecs.getwriter(\u0027utf-8\u0027)(sys.stdout).write(u\u0027test\u0027)\n  Traceback (most recent call last):\n    File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n    File \"/usr/lib64/python3.7/codecs.py\", line 378, in write\n      self.stream.write(data)\n  TypeError: write() argument must be str, not bytes\n\nThis is documented on StackOverflow too [1]. I\u0027m still looking for an alternative to this but any suggestions off the top of your head, Thomas?\n\n[1] https://stackoverflow.com/questions/4374455/how-to-set-sys-stdout-encoding-in-python-3","commit_id":"d272d6f3df2610a62f81e2ca26798ea8a6674b06"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"a4e7c4cd988897ee8c93ed2d7bdc7e88d47fa756","unresolved":false,"context_lines":[{"line_number":2598,"context_line":""},{"line_number":2599,"context_line":"    if data and data[-1] !\u003d \u0027\\n\u0027:"},{"line_number":2600,"context_line":"        data +\u003d \u0027\\n\u0027"},{"line_number":2601,"context_line":"    codecs.getwriter(\u0027utf-8\u0027)(sys.stdout).write(data)"},{"line_number":2602,"context_line":""},{"line_number":2603,"context_line":""},{"line_number":2604,"context_line":"@utils.arg(\u0027server\u0027, metavar\u003d\u0027\u003cserver\u003e\u0027, help\u003d_(\u0027Name or ID of server.\u0027))"}],"source_content_type":"text/x-python","patch_set":3,"id":"3fce034c_c12c669b","line":2601,"range":{"start_line":2601,"start_character":0,"end_line":2601,"end_character":53},"in_reply_to":"5fc1f717_b6b9f779","updated":"2019-04-11 15:05:49.000000000","message":"So apparently we have 0 test coverage of this? Otherwise it could have been caught in the py3 unit tests maybe?","commit_id":"d272d6f3df2610a62f81e2ca26798ea8a6674b06"}]}
