)]}'
{"doc/source/usage.rst":[{"author":{"_account_id":6928,"name":"Ben Nemec","email":"openstack@nemebean.com","username":"bnemec"},"change_message_id":"dc6a532560cac04205852bf86bb1db7ea8289cc6","unresolved":false,"context_lines":[{"line_number":104,"context_line":"    try:"},{"line_number":105,"context_line":"        do_something()"},{"line_number":106,"context_line":"    except Exception as err:"},{"line_number":107,"context_line":"        LOG.exception(unicode(err))"},{"line_number":108,"context_line":""},{"line_number":109,"context_line":"Failure to do this for exceptions or other objects containing"},{"line_number":110,"context_line":"translatable strings from ``oslo.i18n`` results in an exception when"}],"source_content_type":"text/x-rst","patch_set":2,"id":"ba7be1f8_0b2a61e7","line":107,"updated":"2015-02-26 19:46:51.000000000","message":"This isn\u0027t py3 compatible, should we suggest six.text_type() instead?","commit_id":"972a9b62b9d6de18d40a748f0d06645eaf4a1e93"},{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"21973814a331acee5ad250bb61a84ddb45c1e49d","unresolved":false,"context_lines":[{"line_number":104,"context_line":"    try:"},{"line_number":105,"context_line":"        do_something()"},{"line_number":106,"context_line":"    except Exception as err:"},{"line_number":107,"context_line":"        LOG.exception(unicode(err))"},{"line_number":108,"context_line":""},{"line_number":109,"context_line":"Failure to do this for exceptions or other objects containing"},{"line_number":110,"context_line":"translatable strings from ``oslo.i18n`` results in an exception when"}],"source_content_type":"text/x-rst","patch_set":2,"id":"ba7be1f8_e4ecec2b","line":107,"in_reply_to":"ba7be1f8_0b2a61e7","updated":"2015-03-02 15:20:05.000000000","message":"Done","commit_id":"972a9b62b9d6de18d40a748f0d06645eaf4a1e93"},{"author":{"_account_id":6601,"name":"James Carey","email":"jecarey@yerac.com","username":"jecarey"},"change_message_id":"2cb7458cb9521d0f5e47276f90bb9d8c570b87c9","unresolved":false,"context_lines":[{"line_number":82,"context_line":"therefore need to be passed as unicode objects -- that\u0027s strictly"},{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"}],"source_content_type":"text/x-rst","patch_set":3,"id":"ba7be1f8_085bce2e","line":85,"updated":"2015-03-02 17:21:47.000000000","message":"Isn\u0027t it LOG.debug that is the big problem?   Since they aren\u0027t translated so the _() and _Lx() functions are not used?\n\nAs mentioned below, I thought exceptions should use _LE().","commit_id":"1e5e2f9ccc17171dcd9c562298ff82dda37da85a"},{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"474673e48602689c7f3ebb3f5ed6f6104401a8e2","unresolved":false,"context_lines":[{"line_number":82,"context_line":"therefore need to be passed as unicode objects -- that\u0027s strictly"},{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"}],"source_content_type":"text/x-rst","patch_set":3,"id":"ba7be1f8_be6118aa","line":85,"in_reply_to":"ba7be1f8_085bce2e","updated":"2015-03-02 17:56:42.000000000","message":"We didn\u0027t find any debug() calls that weren\u0027t being passed string arguments. We had several cases where LOG.exception(err) was being used.","commit_id":"1e5e2f9ccc17171dcd9c562298ff82dda37da85a"},{"author":{"_account_id":6601,"name":"James Carey","email":"jecarey@yerac.com","username":"jecarey"},"change_message_id":"2cb7458cb9521d0f5e47276f90bb9d8c570b87c9","unresolved":false,"context_lines":[{"line_number":103,"context_line":"    try:"},{"line_number":104,"context_line":"        do_something()"},{"line_number":105,"context_line":"    except Exception as err:"},{"line_number":106,"context_line":"        LOG.exception(u\"do_something couldn\u0027t do something: %s\", err)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"    # New style (alternate)"},{"line_number":109,"context_line":"    import six"}],"source_content_type":"text/x-rst","patch_set":3,"id":"ba7be1f8_e58303ca","line":106,"updated":"2015-03-02 17:21:47.000000000","message":"Shouldn\u0027t this be using _LE()?   So it would be:\n\n     LOG.exception(_LE(\"do_something couldn\u0027t do something: %s\"), err)\n\nIf this isn\u0027t done the message wouldn\u0027t get lazy translated, only the exception would.\n\n\nIs it worth mentioning that when using the _() or _Lx() functions that they don\u0027t have to be passed u\"...\", but simply \"...\"?","commit_id":"1e5e2f9ccc17171dcd9c562298ff82dda37da85a"},{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"474673e48602689c7f3ebb3f5ed6f6104401a8e2","unresolved":false,"context_lines":[{"line_number":103,"context_line":"    try:"},{"line_number":104,"context_line":"        do_something()"},{"line_number":105,"context_line":"    except Exception as err:"},{"line_number":106,"context_line":"        LOG.exception(u\"do_something couldn\u0027t do something: %s\", err)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"    # New style (alternate)"},{"line_number":109,"context_line":"    import six"}],"source_content_type":"text/x-rst","patch_set":3,"id":"ba7be1f8_9e0534c4","line":106,"in_reply_to":"ba7be1f8_e58303ca","updated":"2015-03-02 17:56:42.000000000","message":"Good point.","commit_id":"1e5e2f9ccc17171dcd9c562298ff82dda37da85a"},{"author":{"_account_id":11904,"name":"Sean McGinnis","email":"sean.mcginnis@gmail.com","username":"SeanM"},"change_message_id":"addf24c1191348821cb7806827b20490d8bbf497","unresolved":false,"context_lines":[{"line_number":72,"context_line":"object as the first argument so the log message includes the location"},{"line_number":73,"context_line":"information."},{"line_number":74,"context_line":""},{"line_number":75,"context_line":"No more implicit conversion to unicode/str"},{"line_number":76,"context_line":"------------------------------------------"},{"line_number":77,"context_line":""},{"line_number":78,"context_line":"The old :class:`ContextAdapter` used to convert anything given to it"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_b15bdb52","line":75,"updated":"2015-03-03 14:54:12.000000000","message":"This really concerns me. There has been A LOT of confusion around logging and using six.text_type and when and when not to do conversion ahead of time. \n\nIf we can do anything to wrap this and hide these details from the users of the logger it will be better overall. I can almost guarantee there are going to be issues and conflicting information in code reviews.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":6491,"name":"xing-yang","email":"xingyang105@gmail.com","username":"xing-yang"},"change_message_id":"a839dddeaabd98aad241e1ae31a06aad42e83dc9","unresolved":false,"context_lines":[{"line_number":72,"context_line":"object as the first argument so the log message includes the location"},{"line_number":73,"context_line":"information."},{"line_number":74,"context_line":""},{"line_number":75,"context_line":"No more implicit conversion to unicode/str"},{"line_number":76,"context_line":"------------------------------------------"},{"line_number":77,"context_line":""},{"line_number":78,"context_line":"The old :class:`ContextAdapter` used to convert anything given to it"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_2cd6904f","line":75,"in_reply_to":"ba7be1f8_a969affa","updated":"2015-03-04 04:41:40.000000000","message":"This will break some existing code. Code like LOG.exception(ex) or LOG.debug(ex) will start to throw exceptions.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":7198,"name":"Jay Bryant","email":"jungleboyj@electronicjungle.net","username":"jsbryant"},"change_message_id":"e4e8c07bf05089d7bfaca33360f1dc2c6760eaf2","unresolved":false,"context_lines":[{"line_number":72,"context_line":"object as the first argument so the log message includes the location"},{"line_number":73,"context_line":"information."},{"line_number":74,"context_line":""},{"line_number":75,"context_line":"No more implicit conversion to unicode/str"},{"line_number":76,"context_line":"------------------------------------------"},{"line_number":77,"context_line":""},{"line_number":78,"context_line":"The old :class:`ContextAdapter` used to convert anything given to it"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_a969affa","line":75,"in_reply_to":"ba7be1f8_b15bdb52","updated":"2015-03-03 16:40:05.000000000","message":"Agreed.  Think we need more specific examples in here.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"671faca59649f4dacd35cff5cedc705b21c284a2","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_cfad0386","line":86,"updated":"2015-03-03 17:04:52.000000000","message":"Another case is LOG.debug that is usually passed an untranslated string (which is not unicode in py2.x). Does it mean LOG.debug(\u0027message\u0027) won\u0027t work now? Or the issue is less severe?","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":11904,"name":"Sean McGinnis","email":"sean.mcginnis@gmail.com","username":"SeanM"},"change_message_id":"2a6a52c6f3d6a169f4b8f58fa705a069896613b3","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_1aa57203","line":86,"in_reply_to":"9a80dd14_0670c2da","updated":"2015-03-09 19:35:16.000000000","message":"Right, not with the straight Python logger:\n\nhttp://paste.openstack.org/show/191063/\n\nAll logging works as expected in that test script.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"dd01b6f178bef97bc8b7d5f54d355ec4839b2b1a","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_5da604af","line":86,"in_reply_to":"9a80dd14_1a3bb2eb","updated":"2015-03-09 20:08:16.000000000","message":"Got it, thanks.\n\nI agree with you. I\u0027m very new to this problem -- I got here from another review where I asked \"why is u needed in the format string now?\" and once I heard the answer, I thought, \"I wish we could take care of this automatically in the logger somehow.\"","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"713ffe6a5638d30cb6f3b7cccf3b8fe2fa61d962","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_5afb6a78","line":86,"in_reply_to":"9a80dd14_1aa57203","updated":"2015-03-09 19:46:27.000000000","message":"Your code works for me too (in an environment where I have cinder installed).\n\nI don\u0027t know if you saw my last pastebin where I got the failure with the plain python logger, was this, am I missing something?\n\nhttp://pastebin.com/R9GZV8e8","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":11904,"name":"Sean McGinnis","email":"sean.mcginnis@gmail.com","username":"SeanM"},"change_message_id":"a150afaa9182eb59dcf18bbbf6cdce7cb45a61c9","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_e082b6c6","line":86,"in_reply_to":"9a80dd14_407aa224","updated":"2015-03-09 18:27:50.000000000","message":"That is odd. I had tested your first one (LOG.debug(\u0027%s\u0027, exp)) and it had worked for me.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":11904,"name":"Sean McGinnis","email":"sean.mcginnis@gmail.com","username":"SeanM"},"change_message_id":"f66a3b64ef3ae24c2023400c5e608a767214d301","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_1a3bb2eb","line":86,"in_reply_to":"9a80dd14_5afb6a78","updated":"2015-03-09 19:55:19.000000000","message":"Yep, I saw that. I\u0027m not sure what secret sauce this logger is providing over the top of the base Python logger, but whatever it is I would love to see it carried forward into any kind of replacement.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"f09f42e13538712e523229b0d09047953c53a5d3","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_fb707c09","line":86,"in_reply_to":"9a80dd14_5da604af","updated":"2015-03-10 13:56:36.000000000","message":"Automatically converting byte strings to unicode requires us to make assumptions about the original inputs. As we move to Python 3, developers are going to need to learn about the distinction between unicode and byte strings and this is only one example of a place where they may cause us trouble.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":11904,"name":"Sean McGinnis","email":"sean.mcginnis@gmail.com","username":"SeanM"},"change_message_id":"42d453ab4e39f6ef45090f50ff2b8c47efda9a77","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_c6322aa6","line":86,"in_reply_to":"9a80dd14_6b0227b5","updated":"2015-03-09 19:11:59.000000000","message":"I see the difference now, and it reinforces my note above about this causing confusion. WIth the oslo_logging in your example these do fail. In the current logger, not the incubated oslo version, this is handled correctly and all variations I have tried work fine.\n\nI would really like to see this behavior carried forward. The need to wrap anything that might contain unicode in six.text_type is not always obvious and I\u0027m sure will lead to issues.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":11904,"name":"Sean McGinnis","email":"sean.mcginnis@gmail.com","username":"SeanM"},"change_message_id":"e3e5ed06dff45b4a6c51472d778479b6a839d452","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_6b0227b5","line":86,"in_reply_to":"9a80dd14_a04d1e9c","updated":"2015-03-09 18:44:12.000000000","message":"I can\u0027t find my original test code to compare, but I am able to reproduce your error on my system. I am also using 2.7.6.\n\nThanks for catching that and pointing it out. There\u0027s obviously some cases where the logger cannot handle it correctly and we need to explicitly use six.text_type(). \n\nIt appears I have been giving out bad advice and may have some cleanup to do. I\u0027m very glad you called this out.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"50fb1ff59e2dff9591e110af1dbf1d36f04434b8","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_407aa224","line":86,"in_reply_to":"9a80dd14_a1de296b","updated":"2015-03-09 18:23:19.000000000","message":"What sort of test took care? I tried the following code:\n\nhttp://pastebin.com/9QTGU2tv\n\nAnd only the second LOG.debug statement worked for me:\n\n UnicodeEncodeError: \u0027ascii\u0027 codec can\u0027t encode character u\u0027\\xe9\u0027 in position 0: ordinal not in range(128)\n Logged from file t.py, line 16\n é","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":11904,"name":"Sean McGinnis","email":"sean.mcginnis@gmail.com","username":"SeanM"},"change_message_id":"4bd7ee125ca2bcdd736573d5cc1553adc32d3ca7","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_a1de296b","line":86,"in_reply_to":"9a80dd14_b9782bc5","updated":"2015-03-07 20:07:34.000000000","message":"Actually, from what we\u0027ve tested LOG.debug(\u0027err \u003d %s\u0027, ex) will be fine. The logger actually does take care of handling unicode strings correctly in that case.\n\nThe problems happen when someone does something like LOG.debug(\u0027err \u003d %s\u0027 % ex). This will result in the string formatting to happen before being passed to the logger, which will cause a problem with unicode. As long as ex is passed along as a parameter to the log call the logger takes care of it.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":6601,"name":"James Carey","email":"jecarey@yerac.com","username":"jecarey"},"change_message_id":"1d9bf67a7e7dda6ec0ff948186bd982f357efe84","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_b9782bc5","line":86,"in_reply_to":"9a80dd14_bfc34289","updated":"2015-03-07 00:10:03.000000000","message":"If it is simply LOG.debug(\u003cstr\u003e) it isn\u0027t a problem.   \n\nAFAIK: The problem only occurs when there is replacement text applied to a non-unicode format string.  If the replacement objects are directly str or unicode, Python can figure things out and it works.   If, on the other hand, the replacement object has a different type, such as Exception, it coerces the replacement object to the type of the format string.   So in the case of LOG.debug(\u0027err \u003d %s\u0027, ex), because ex is an exception, it will do str(ex) before using it as replacement text.   If the exception message is either unicode or an oslo.i18n message (which doesn\u0027t support str()), it will fail.\n\nNote you can get some really interesting results because of the special handling of unicode and str.  The following would work:  LOG.debug(\u0027%s \u003d %s\u0027, (u\u0027err\u0027, ex)) because the first replacement involves a str and a unicode, so the result is a unicode, thus when ex is applied it is being applied to a unicode so unicode(ex) is used instead of str(ex).   If the parameters are reversed it fails.\n\nThe other option, because debug logs don\u0027t support translation, would be to require that six.text_type by used on the problematic parameters.  So it would be LOG.debug(\u0027err \u003d %s\u0027, six.text_type(ex)). \n\nWhatever we decided to do, we should see if we can come up with a hacking check for this.   I don\u0027t know that we can easily get the specific case, but maybe have a broader requirement.  For example, all parameters have to have six.text_type() unless they are a static string OR any format with replacement text must be u\u0027...\u0027.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"c5ba17924de03cdb551412bc64535dcf7fd0ef7e","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_0670c2da","line":86,"in_reply_to":"9a80dd14_c6322aa6","updated":"2015-03-09 19:31:44.000000000","message":"Hm, I get the same result without oslo_log in 2.7.6: http://pastebin.com/R9GZV8e8","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"ed8fc55a527742458fae97bcd026b3bc492313d8","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_a04d1e9c","line":86,"in_reply_to":"9a80dd14_e082b6c6","updated":"2015-03-09 18:32:56.000000000","message":"Are you using python 3 by chance? I tried this with 2.7.6.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"32ded30146dc3423b704a36e555eed7a7acbd649","unresolved":false,"context_lines":[{"line_number":83,"context_line":":class:`unicode`, not :class:`str`."},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"The most common place to encounter this is where :meth:`Logger.exception`"},{"line_number":86,"context_line":"is used by passing an exception object as the first argument."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"::"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_bfc34289","line":86,"in_reply_to":"ba7be1f8_cfad0386","updated":"2015-03-04 12:01:24.000000000","message":"Looking at output from neutron oslo.log migration patch at: http://logs.openstack.org/38/159638/7/check/check-tempest-dsvm-neutron-pg/6485a22/ I don\u0027t see any errors when LOG.debug(\u003cstr\u003e) is executed. So maybe there is no real problem in this case?","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":6928,"name":"Ben Nemec","email":"openstack@nemebean.com","username":"bnemec"},"change_message_id":"18f2106c0ab2a588cce39206ce2925538a18c888","unresolved":false,"context_lines":[{"line_number":91,"context_line":"    try:"},{"line_number":92,"context_line":"        do_something()"},{"line_number":93,"context_line":"    except Exception as err:"},{"line_number":94,"context_line":"        LOG.exception(err)"},{"line_number":95,"context_line":""},{"line_number":96,"context_line":"Now, the error should be converted to unicode either by calling"},{"line_number":97,"context_line":":func:`six.text_type` or by using a unicode formatting string to"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_8f5cf27e","line":94,"updated":"2015-03-03 15:21:31.000000000","message":"Oh, how did I miss this?  They shouldn\u0027t be passing the exception object to LOG.exception anyway.  The whole point of using that is it includes the exception details for you.  The argument is just supposed to be a message describing what failed.\n\nGiven that quite a few people will probably be reading this doc it would be good to at least mention that this is a bad pattern.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":6491,"name":"xing-yang","email":"xingyang105@gmail.com","username":"xing-yang"},"change_message_id":"a839dddeaabd98aad241e1ae31a06aad42e83dc9","unresolved":false,"context_lines":[{"line_number":91,"context_line":"    try:"},{"line_number":92,"context_line":"        do_something()"},{"line_number":93,"context_line":"    except Exception as err:"},{"line_number":94,"context_line":"        LOG.exception(err)"},{"line_number":95,"context_line":""},{"line_number":96,"context_line":"Now, the error should be converted to unicode either by calling"},{"line_number":97,"context_line":":func:`six.text_type` or by using a unicode formatting string to"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_6c5a48f3","line":94,"in_reply_to":"ba7be1f8_461ae06f","updated":"2015-03-04 04:41:40.000000000","message":"I agree this is bad.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":7198,"name":"Jay Bryant","email":"jungleboyj@electronicjungle.net","username":"jsbryant"},"change_message_id":"e4e8c07bf05089d7bfaca33360f1dc2c6760eaf2","unresolved":false,"context_lines":[{"line_number":91,"context_line":"    try:"},{"line_number":92,"context_line":"        do_something()"},{"line_number":93,"context_line":"    except Exception as err:"},{"line_number":94,"context_line":"        LOG.exception(err)"},{"line_number":95,"context_line":""},{"line_number":96,"context_line":"Now, the error should be converted to unicode either by calling"},{"line_number":97,"context_line":":func:`six.text_type` or by using a unicode formatting string to"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_461ae06f","line":94,"in_reply_to":"ba7be1f8_8f5cf27e","updated":"2015-03-03 16:40:05.000000000","message":"Agreed, I don\u0027t allow people to do this in Cinder if I see it.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"f09f42e13538712e523229b0d09047953c53a5d3","unresolved":false,"context_lines":[{"line_number":91,"context_line":"    try:"},{"line_number":92,"context_line":"        do_something()"},{"line_number":93,"context_line":"    except Exception as err:"},{"line_number":94,"context_line":"        LOG.exception(err)"},{"line_number":95,"context_line":""},{"line_number":96,"context_line":"Now, the error should be converted to unicode either by calling"},{"line_number":97,"context_line":":func:`six.text_type` or by using a unicode formatting string to"}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_bbffe432","line":94,"in_reply_to":"ba7be1f8_8f5cf27e","updated":"2015-03-10 13:56:36.000000000","message":"I\u0027ve updated the example below with a note about that, but we do have code in some of the projects that looks like this and I don\u0027t think we need to add messages to those log calls just to enable adoption of the library. Having the log call not break and having it produce useful information can be handled via separate changesets.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":1736,"name":"Ivan Kolodyazhny","email":"e0ne@e0ne.info","username":"e0ne"},"change_message_id":"4bb594994c71e8238ddd07485f56486447cafa6b","unresolved":false,"context_lines":[{"line_number":104,"context_line":"    try:"},{"line_number":105,"context_line":"        do_something()"},{"line_number":106,"context_line":"    except Exception as err:"},{"line_number":107,"context_line":"        LOG.exception(_LE(u\"do_something couldn\u0027t do something: %s\"), err)"},{"line_number":108,"context_line":""},{"line_number":109,"context_line":"    # New style (alternate)"},{"line_number":110,"context_line":"    import six"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_1f7054db","line":107,"updated":"2015-03-02 23:04:07.000000000","message":"Do we need use six.text_type here?\nIt would be useful to add note about when we should use six.text_type(err) and when pass just err to a logger","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"b5769121da3b4cb9a77b61c0113802c132fd5130","unresolved":false,"context_lines":[{"line_number":104,"context_line":"    try:"},{"line_number":105,"context_line":"        do_something()"},{"line_number":106,"context_line":"    except Exception as err:"},{"line_number":107,"context_line":"        LOG.exception(_LE(u\"do_something couldn\u0027t do something: %s\"), err)"},{"line_number":108,"context_line":""},{"line_number":109,"context_line":"    # New style (alternate)"},{"line_number":110,"context_line":"    import six"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_c2d18358","line":107,"in_reply_to":"ba7be1f8_1f7054db","updated":"2015-03-02 23:14:54.000000000","message":"The first argument to the logger needs to be a unicode object. The format instructions inside that string dictate what the other arguments can be. In this case, the %s converts err to a string when the message is formatted. The *only* reason the second case needs text_type() is there is no separate formatting string.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":6491,"name":"xing-yang","email":"xingyang105@gmail.com","username":"xing-yang"},"change_message_id":"a839dddeaabd98aad241e1ae31a06aad42e83dc9","unresolved":false,"context_lines":[{"line_number":104,"context_line":"    try:"},{"line_number":105,"context_line":"        do_something()"},{"line_number":106,"context_line":"    except Exception as err:"},{"line_number":107,"context_line":"        LOG.exception(_LE(u\"do_something couldn\u0027t do something: %s\"), err)"},{"line_number":108,"context_line":""},{"line_number":109,"context_line":"    # New style (alternate)"},{"line_number":110,"context_line":"    import six"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_cc8ed478","line":107,"in_reply_to":"ba7be1f8_4f55931c","updated":"2015-03-04 04:41:40.000000000","message":"If LOG.exception(_LE(\"xxx\")) already prints out the exception information any way even if the exception err is not provided, why do we need to supply the exception err - LOG.exception(_LE(\"xxx %s\", err)?","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":6601,"name":"James Carey","email":"jecarey@yerac.com","username":"jecarey"},"change_message_id":"92345f3096bc7a2270bfbc6388a83dee4a46c57e","unresolved":false,"context_lines":[{"line_number":104,"context_line":"    try:"},{"line_number":105,"context_line":"        do_something()"},{"line_number":106,"context_line":"    except Exception as err:"},{"line_number":107,"context_line":"        LOG.exception(_LE(u\"do_something couldn\u0027t do something: %s\"), err)"},{"line_number":108,"context_line":""},{"line_number":109,"context_line":"    # New style (alternate)"},{"line_number":110,"context_line":"    import six"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_4f55931c","line":107,"in_reply_to":"ba7be1f8_551e2b0d","updated":"2015-03-03 17:13:03.000000000","message":"I agree, _LE() uses gettext if Python3 and ugettext otherwise, so this will be unicode and the u\" shouldn\u0027t be needed.\n\nThe case where it would be needed is the case of LOG.debug(u\"my message %s\", err), because we don\u0027t translate logs and the err could be translatable, we have to use the u\"\n\nThe problem with using LOG.exception(six.text_type(err)) or any other time that six.text_type() is used on something that supports lazy translation is that it causes translation to be done immediately instead of by the translation handler.   So it would be better to recommend that a string is always provided.   The exception to that would be LOG.debug where it wont\u0027 be translated.   LOG.debug(u\"my message %s\", six.text_type(err)) would be fine.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":1736,"name":"Ivan Kolodyazhny","email":"e0ne@e0ne.info","username":"e0ne"},"change_message_id":"f3c6166bd49133df0972aaa547e3bd2eb0e086b8","unresolved":false,"context_lines":[{"line_number":104,"context_line":"    try:"},{"line_number":105,"context_line":"        do_something()"},{"line_number":106,"context_line":"    except Exception as err:"},{"line_number":107,"context_line":"        LOG.exception(_LE(u\"do_something couldn\u0027t do something: %s\"), err)"},{"line_number":108,"context_line":""},{"line_number":109,"context_line":"    # New style (alternate)"},{"line_number":110,"context_line":"    import six"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_551e2b0d","line":107,"in_reply_to":"ba7be1f8_c2d18358","updated":"2015-03-03 00:05:28.000000000","message":"Thanks for detailed response. AFAIR, _LE and other markers returns unicode object, so do we need add u\u0027\u0027 here? We are trying to make our code Python3 friendly and this sample is confusing a bit","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":7198,"name":"Jay Bryant","email":"jungleboyj@electronicjungle.net","username":"jsbryant"},"change_message_id":"e4e8c07bf05089d7bfaca33360f1dc2c6760eaf2","unresolved":false,"context_lines":[{"line_number":111,"context_line":"    try:"},{"line_number":112,"context_line":"        do_something()"},{"line_number":113,"context_line":"    except Exception as err:"},{"line_number":114,"context_line":"        LOG.exception(six.text_type(err))"},{"line_number":115,"context_line":""},{"line_number":116,"context_line":"Failure to do this for exceptions or other objects containing"},{"line_number":117,"context_line":"translatable strings from ``oslo.i18n`` results in an exception when"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_46b6603f","line":114,"updated":"2015-03-03 16:40:05.000000000","message":"I don\u0027t think that we want to provide this as an example.  This just seems to be bad form to me.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":6491,"name":"xing-yang","email":"xingyang105@gmail.com","username":"xing-yang"},"change_message_id":"a839dddeaabd98aad241e1ae31a06aad42e83dc9","unresolved":false,"context_lines":[{"line_number":111,"context_line":"    try:"},{"line_number":112,"context_line":"        do_something()"},{"line_number":113,"context_line":"    except Exception as err:"},{"line_number":114,"context_line":"        LOG.exception(six.text_type(err))"},{"line_number":115,"context_line":""},{"line_number":116,"context_line":"Failure to do this for exceptions or other objects containing"},{"line_number":117,"context_line":"translatable strings from ``oslo.i18n`` results in an exception when"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_acf52084","line":114,"in_reply_to":"ba7be1f8_2f23ffbd","updated":"2015-03-04 04:41:40.000000000","message":"+1","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":6601,"name":"James Carey","email":"jecarey@yerac.com","username":"jecarey"},"change_message_id":"92345f3096bc7a2270bfbc6388a83dee4a46c57e","unresolved":false,"context_lines":[{"line_number":111,"context_line":"    try:"},{"line_number":112,"context_line":"        do_something()"},{"line_number":113,"context_line":"    except Exception as err:"},{"line_number":114,"context_line":"        LOG.exception(six.text_type(err))"},{"line_number":115,"context_line":""},{"line_number":116,"context_line":"Failure to do this for exceptions or other objects containing"},{"line_number":117,"context_line":"translatable strings from ``oslo.i18n`` results in an exception when"}],"source_content_type":"text/x-rst","patch_set":4,"id":"ba7be1f8_2f23ffbd","line":114,"in_reply_to":"ba7be1f8_46b6603f","updated":"2015-03-03 17:13:03.000000000","message":"I agree.  It prevents lazy translation of the err.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"f09f42e13538712e523229b0d09047953c53a5d3","unresolved":false,"context_lines":[{"line_number":111,"context_line":"    try:"},{"line_number":112,"context_line":"        do_something()"},{"line_number":113,"context_line":"    except Exception as err:"},{"line_number":114,"context_line":"        LOG.exception(six.text_type(err))"},{"line_number":115,"context_line":""},{"line_number":116,"context_line":"Failure to do this for exceptions or other objects containing"},{"line_number":117,"context_line":"translatable strings from ``oslo.i18n`` results in an exception when"}],"source_content_type":"text/x-rst","patch_set":4,"id":"9a80dd14_9bfa2073","line":114,"in_reply_to":"ba7be1f8_46b6603f","updated":"2015-03-10 13:56:36.000000000","message":"We have projects using this style, so the example demonstrates how to fix that existing code in a minimally intrusive way.","commit_id":"8dc20c98d82c9a483e61394082ada74cee2234e0"},{"author":{"_account_id":11904,"name":"Sean McGinnis","email":"sean.mcginnis@gmail.com","username":"SeanM"},"change_message_id":"82cb136d9bc14557cf70fd88949b8a71a992c6a2","unresolved":false,"context_lines":[{"line_number":72,"context_line":"object as the first argument so the log message includes the location"},{"line_number":73,"context_line":"information."},{"line_number":74,"context_line":""},{"line_number":75,"context_line":"No more implicit conversion to unicode/str"},{"line_number":76,"context_line":"------------------------------------------"},{"line_number":77,"context_line":""},{"line_number":78,"context_line":"The old :class:`ContextAdapter` used to convert anything given to it"}],"source_content_type":"text/x-rst","patch_set":5,"id":"7a75e904_00bb1a0f","line":75,"updated":"2015-03-21 13:29:22.000000000","message":"I just want to note my concern with this one again. We are going to need a lot of cleanup to the existing code or this is going to cause problems.","commit_id":"35e51bc38ebf7be2b67344f16186eb37ff693a4d"}]}
