Skip to content

Commit 14ba761

Browse files
authored
bpo-44235: Remove deprecated functions in the gettext module. (GH-26378)
1 parent 5ffa58c commit 14ba761

File tree

5 files changed

+40
-447
lines changed

5 files changed

+40
-447
lines changed

Doc/library/gettext.rst

Lines changed: 7 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ class-based API instead.
4646
returned. [#]_
4747

4848

49-
.. function:: bind_textdomain_codeset(domain, codeset=None)
50-
51-
Bind the *domain* to *codeset*, changing the encoding of byte strings
52-
returned by the :func:`lgettext`, :func:`ldgettext`, :func:`lngettext`
53-
and :func:`ldngettext` functions.
54-
If *codeset* is omitted, then the current binding is returned.
55-
56-
.. deprecated-removed:: 3.8 3.10
57-
58-
5949
.. function:: textdomain(domain=None)
6050

6151
Change or query the current global domain. If *domain* is ``None``, then the
@@ -108,29 +98,6 @@ class-based API instead.
10898
.. versionadded:: 3.8
10999

110100

111-
.. function:: lgettext(message)
112-
.. function:: ldgettext(domain, message)
113-
.. function:: lngettext(singular, plural, n)
114-
.. function:: ldngettext(domain, singular, plural, n)
115-
116-
Equivalent to the corresponding functions without the ``l`` prefix
117-
(:func:`.gettext`, :func:`dgettext`, :func:`ngettext` and :func:`dngettext`),
118-
but the translation is returned as a byte string encoded in the preferred
119-
system encoding if no other encoding was explicitly set with
120-
:func:`bind_textdomain_codeset`.
121-
122-
.. warning::
123-
124-
These functions should be avoided in Python 3, because they return
125-
encoded bytes. It's much better to use alternatives which return
126-
Unicode strings instead, since most Python applications will want to
127-
manipulate human readable text as strings instead of bytes. Further,
128-
it's possible that you may get unexpected Unicode-related exceptions
129-
if there are encoding problems with the translated strings.
130-
131-
.. deprecated-removed:: 3.8 3.10
132-
133-
134101
Note that GNU :program:`gettext` also defines a :func:`dcgettext` method, but
135102
this was deemed not useful and so it is currently unimplemented.
136103

@@ -181,7 +148,7 @@ install themselves in the built-in namespace as the function :func:`_`.
181148
the environment variables.
182149

183150

184-
.. function:: translation(domain, localedir=None, languages=None, class_=None, fallback=False, codeset=None)
151+
.. function:: translation(domain, localedir=None, languages=None, class_=None, fallback=False)
185152

186153
Return a :class:`*Translations` instance based on the *domain*, *localedir*,
187154
and *languages*, which are first passed to :func:`find` to get a list of the
@@ -205,15 +172,13 @@ install themselves in the built-in namespace as the function :func:`_`.
205172
.. versionchanged:: 3.3
206173
:exc:`IOError` used to be raised instead of :exc:`OSError`.
207174

208-
.. deprecated-removed:: 3.8 3.10
209-
The *codeset* parameter.
210-
175+
.. versionchanged:: 3.11
176+
*codeset* parameter is removed.
211177

212-
.. function:: install(domain, localedir=None, codeset=None, names=None)
178+
.. function:: install(domain, localedir=None, *, names=None)
213179

214180
This installs the function :func:`_` in Python's builtins namespace, based on
215-
*domain*, *localedir*, and *codeset* which are passed to the function
216-
:func:`translation`.
181+
*domain* and *localedir* which are passed to the function :func:`translation`.
217182

218183
For the *names* parameter, please see the description of the translation
219184
object's :meth:`~NullTranslations.install` method.
@@ -228,9 +193,8 @@ install themselves in the built-in namespace as the function :func:`_`.
228193
builtins namespace, so it is easily accessible in all modules of your
229194
application.
230195

231-
.. deprecated-removed:: 3.8 3.10
232-
The *codeset* parameter.
233-
196+
.. versionchanged:: 3.11
197+
*names* is now a keyword-only parameter.
234198

235199
The :class:`NullTranslations` class
236200
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -294,22 +258,6 @@ are the methods of :class:`!NullTranslations`:
294258
.. versionadded:: 3.8
295259

296260

297-
.. method:: lgettext(message)
298-
.. method:: lngettext(singular, plural, n)
299-
300-
Equivalent to :meth:`.gettext` and :meth:`.ngettext`, but the translation
301-
is returned as a byte string encoded in the preferred system encoding
302-
if no encoding was explicitly set with :meth:`set_output_charset`.
303-
Overridden in derived classes.
304-
305-
.. warning::
306-
307-
These methods should be avoided in Python 3. See the warning for the
308-
:func:`lgettext` function.
309-
310-
.. deprecated-removed:: 3.8 3.10
311-
312-
313261
.. method:: info()
314262

315263
Return the "protected" :attr:`_info` variable, a dictionary containing
@@ -321,21 +269,6 @@ are the methods of :class:`!NullTranslations`:
321269
Return the encoding of the message catalog file.
322270

323271

324-
.. method:: output_charset()
325-
326-
Return the encoding used to return translated messages in :meth:`.lgettext`
327-
and :meth:`.lngettext`.
328-
329-
.. deprecated-removed:: 3.8 3.10
330-
331-
332-
.. method:: set_output_charset(charset)
333-
334-
Change the encoding used to return translated messages.
335-
336-
.. deprecated-removed:: 3.8 3.10
337-
338-
339272
.. method:: install(names=None)
340273

341274
This method installs :meth:`.gettext` into the built-in namespace,
@@ -450,22 +383,6 @@ unexpected, or if other problems occur while reading the file, instantiating a
450383
.. versionadded:: 3.8
451384

452385

453-
.. method:: lgettext(message)
454-
.. method:: lngettext(singular, plural, n)
455-
456-
Equivalent to :meth:`.gettext` and :meth:`.ngettext`, but the translation
457-
is returned as a byte string encoded in the preferred system encoding
458-
if no encoding was explicitly set with
459-
:meth:`~NullTranslations.set_output_charset`.
460-
461-
.. warning::
462-
463-
These methods should be avoided in Python 3. See the warning for the
464-
:func:`lgettext` function.
465-
466-
.. deprecated-removed:: 3.8 3.10
467-
468-
469386
Solaris message catalog support
470387
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
471388

Doc/whatsnew/3.11.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,15 @@ Removed
169169
Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization Configuration
170170
<init-config>` instead (:pep:`587`).
171171
(Contributed by Victor Stinner in :issue:`44113`.)
172+
173+
* The following deprecated functions and methods are removed in the :mod:`gettext`
174+
module: :func:`~gettext.lgettext`, :func:`~gettext.ldgettext`,
175+
:func:`~gettext.lngettext` and :func:`~gettext.ldngettext`.
176+
177+
Function :func:`~gettext.bind_textdomain_codeset`, methods
178+
:meth:`~gettext.NullTranslations.output_charset` and
179+
:meth:`~gettext.NullTranslations.set_output_charset`, and the *codeset*
180+
parameter of functions :func:`~gettext.translation` and
181+
:func:`~gettext.install` are also removed, since they are only used for
182+
the ``l*gettext()`` functions.
183+
(Contributed by Dong-hee Na and Serhiy Storchaka in :issue:`44235`.)

0 commit comments

Comments
 (0)