|
From: <mi...@us...> - 2022-12-02 23:07:36
|
Revision: 9303
http://sourceforge.net/p/docutils/code/9303
Author: milde
Date: 2022-12-02 23:07:33 +0000 (Fri, 02 Dec 2022)
Log Message:
-----------
Allow empty string as encoding value (to re-activate default).
Value `None` cannot be specified on the command line.
Use ``--input-encoding=""`` go back to Docutil's default behaviur
(use encoding indicated in the file or fallbacks)
if a config file sets "input_encoding" to another value.
Modified Paths:
--------------
trunk/docutils/docutils/frontend.py
trunk/docutils/test/test_io.py
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2022-12-02 17:14:05 UTC (rev 9302)
+++ trunk/docutils/docutils/frontend.py 2022-12-02 23:07:33 UTC (rev 9303)
@@ -92,6 +92,8 @@
def validate_encoding(setting, value, option_parser,
config_parser=None, config_section=None):
+ if value == '':
+ return None # allow overwriting a config file value
try:
codecs.lookup(value)
except LookupError:
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2022-12-02 17:14:05 UTC (rev 9302)
+++ trunk/docutils/test/test_io.py 2022-12-02 23:07:33 UTC (rev 9303)
@@ -70,8 +70,9 @@
self.assertEqual(io.check_encoding(io.FileInput(), 'ascii'), None)
# stream.encoding does not exist:
self.assertEqual(io.check_encoding(BBuf, 'ascii'), None)
- # encoding is None:
+ # encoding is None or empty string:
self.assertEqual(io.check_encoding(mock_stdout, None), None)
+ self.assertEqual(io.check_encoding(mock_stdout, ''), None)
# encoding is invalid
self.assertEqual(io.check_encoding(mock_stdout, 'UTF-9'), None)
@@ -142,6 +143,7 @@
def test_heuristics_no_utf8(self):
# if no encoding is given and decoding with 'utf-8' fails,
# use either the locale encoding (if specified) or 'latin-1':
+ # Provisional: the second fallback 'latin-1' will be dropped
probed_encodings = (io._locale_encoding, 'latin-1') # noqa
input = io.FileInput(
source_path=os.path.join(DATA_ROOT, 'latin1.txt'))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|