According to code here: https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/docutils/utils/error_reporting.py#l55.
If a value error like 'unknown locale: en-us' is generated, variable locale_encoding will not be initialized.Causing line codecs.lookup(locale_encoding or '') # None -> '' to complain using undeclared locale_encoding. This bug is a blocker on our current work.
On 2017-06-22, Sirui Tan via Docutils-develop wrote in gmane.text.docutils.devel:
I cannot see a bug here, it is the expected and documented behaviour:
# If no valid guess can be made, locale_encoding is set to
None:--- error_reporting.py line 41
However, this is is catched by exception handling in line 61.
I don't know what you are trying to achieve or what you would expect as
reaction if no valid locale encoding can be determined.
The correct usage would be to correctly handle the case that
locale_encoding == None, e.g. like in frontend.py::Okay, here is the workflow:
* On line 43 import
locale, noImportErroris triggered so enterelseblock on line 46 with namelocale_encodingundefined.* Run line 48 and
ValueErroris thrown.* error.args is inspected by
ifblock on line 55. In our case the error message is not'unknown locale: UTF-8'so the contents inifblock will not be executed.locale_encodingis still undefined.* except block on line 57 is ignored since
ValueErrorhas already been captured.locale_encodingis still undefined.* Run line 60,
codecs.lookup(locale_encoding or ''), sincelocale_encodingis undefined, exception (notLookupError) will be raised.* Exception handling on line 60 only capture
LookupError, so exception raised on line 60 will be thrown and (porbably) terminate the process execution.Hope that helps!
Yes, with this description I can spot the problem and solve it.
Should be fixed with revision 8119.