|
From: <mi...@us...> - 2023-01-10 13:13:19
|
Revision: 9314
http://sourceforge.net/p/docutils/code/9314
Author: milde
Date: 2023-01-10 13:13:17 +0000 (Tue, 10 Jan 2023)
Log Message:
-----------
`locale.getdefaultlocale()` is deprecated in Python 0.11
Let `smartquotes.py` to use `locale.getlocale` instead.
(Only used if this module is called as standalone application.)
Suppress warning in `docutils.io`:
* Don't change current behaviour without advance warning.
* The deprecated function is called inside a try-block with catchall,
so this will not lead to errors once it is removed
(if we were to keep the code until then).
Fixes [bugs:#464].
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/io.py
trunk/docutils/docutils/utils/smartquotes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2023-01-10 08:58:28 UTC (rev 9313)
+++ trunk/docutils/HISTORY.txt 2023-01-10 13:13:17 UTC (rev 9314)
@@ -158,6 +158,7 @@
- Use "utf-8-sig" instead of Python's default encoding if the
`input_encoding`_ setting is None.
- Fix error when reading of UTF-16 encoded source without trailing newline.
+ - Suppress deprecation warning (fixes bug #464).
* docutils/parsers/__init__.py
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2023-01-10 08:58:28 UTC (rev 9313)
+++ trunk/docutils/docutils/io.py 2023-01-10 13:13:17 UTC (rev 9314)
@@ -27,8 +27,11 @@
# before importing this module
try:
# Return locale encoding also in UTF-8 mode
- _locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
- _locale_encoding = _locale_encoding.lower()
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ _locale_encoding = (locale.getlocale()[1]
+ or locale.getdefaultlocale()[1])
+ _locale_encoding = _locale_encoding.lower()
except ValueError as error: # OS X may set UTF-8 without language code
# See https://bugs.python.org/issue18378 fixed in 3.8
# and https://sourceforge.net/p/docutils/bugs/298/.
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2023-01-10 08:58:28 UTC (rev 9313)
+++ trunk/docutils/docutils/utils/smartquotes.py 2023-01-10 13:13:17 UTC (rev 9314)
@@ -897,7 +897,7 @@
import locale
try:
locale.setlocale(locale.LC_ALL, '') # set to user defaults
- defaultlanguage = locale.getdefaultlocale()[0]
+ defaultlanguage = locale.getlocale()[0]
except: # noqa catchall
defaultlanguage = 'en'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|