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:
locale, noImportErroris triggered so enterelseblock on line 46 with namelocale_encodingundefined.ValueErroris thrown.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.ValueErrorhas already been captured.locale_encodingis still undefined.codecs.lookup(locale_encoding or ''), sincelocale_encodingis undefined, exception (notLookupError) will be raised.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.