diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2022-01-11 17:39:49 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2022-01-11 17:39:49 +0000 |
| commit | 923b5e793ee8e77d4601a5be13ae71e9c988c35e (patch) | |
| tree | 0d36416c831b2cc485d7cf1585208a7485bb47ed /docutils/io.py | |
| parent | 30ce711b7a83d3152118c49d431ec97b7ed3b95a (diff) | |
| download | docutils-923b5e793ee8e77d4601a5be13ae71e9c988c35e.tar.gz | |
Module "locale" is supported by Jython since version 2.7.2.
Cf. https://github.com/jython/jython/commit/c5509579
Jython does not support Python3 at the moment,
so we don't need to care about earlier versions in Docutils >= 0.19.
git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk/docutils@8941 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/io.py')
| -rw-r--r-- | docutils/io.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/docutils/io.py b/docutils/io.py index a0b75ff51..2daf8f251 100644 --- a/docutils/io.py +++ b/docutils/io.py @@ -10,10 +10,7 @@ exist for a variety of input/output mechanisms. __docformat__ = 'reStructuredText' import codecs -try: - import locale # module missing in Jython -except ImportError: - pass +import locale import os import re import sys @@ -116,9 +113,9 @@ class Input(TransformSpec): """ if self.encoding and self.encoding.lower() == 'unicode': assert isinstance(data, str), ('input encoding is "unicode" ' - 'but input is not a str object') + 'but input is not a `str` object') if isinstance(data, str): - # Accept unicode even if self.encoding != 'unicode'. + # Accept unicode string even if self.encoding != 'unicode'. return data if self.encoding: # We believe the user/application when the encoding is @@ -144,8 +141,8 @@ class Input(TransformSpec): # Return decoded, removing BOMs. return decoded.replace(u'\ufeff', u'') except (UnicodeError, LookupError) as err: - error = err # in Python 3, the <exception instance> is - # local to the except clause + # keep exception instance for use outside of the "for" loop. + error = err raise UnicodeError( 'Unable to decode input data. Tried the following encodings: ' '%s.\n(%s)' % (', '.join([repr(enc) for enc in encodings]), |
