Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of deprecated gettext.bind_textdomain_codeset #2276

Closed
Arfrever opened this issue Nov 15, 2020 · 1 comment
Closed

Usage of deprecated gettext.bind_textdomain_codeset #2276

Arfrever opened this issue Nov 15, 2020 · 1 comment

Comments

@Arfrever
Copy link

When Python warnings are enabled:

$ export PYTHONWARNINGS="d"
$ ibus-setup
/usr/share/ibus/setup/i18n.py:45: DeprecationWarning: bind_textdomain_codeset() is deprecated
  gettext.bind_textdomain_codeset(domainname, 'UTF-8')

https://docs.python.org/3.9/library/gettext.html#gettext.bind_textdomain_codeset says about gettext.bind_textdomain_codeset:

Bind the domain to codeset, changing the encoding of byte strings returned by the lgettext(), ldgettext(), lngettext() and ldngettext() functions.
...
Deprecated since version 3.8, will be removed in version 3.10.

IBus does not use any of gettext.lgettext, gettext.ldgettext, gettext.lngettext, gettext.ldngettext, which are also deprecated and scheduled for deletion:
https://docs.python.org/3.9/library/gettext.html#gettext.lgettext

Possible fix:

--- ui/gtk2/i18n.py
+++ ui/gtk2/i18n.py
@@ -38,11 +38,9 @@ def init_textdomain(domainname):
     # operating systems like FreeBSD
     try:
         locale.bindtextdomain(domainname, LOCALEDIR)
-        locale.bind_textdomain_codeset(domainname, 'UTF-8')
     except AttributeError:
         pass
     gettext.bindtextdomain(domainname, LOCALEDIR)
-    gettext.bind_textdomain_codeset(domainname, 'UTF-8')
 
 def gettext_engine_longname(engine):
     name = engine.get_name()
fujiwarat added a commit that referenced this issue Nov 4, 2021
setup/i18n.py is a symlink of ui/gtk2/i18n.py
env PYTHONWARNINGS='d' ibus-setup

BUG=#2276
@fujiwarat fujiwarat self-assigned this Nov 4, 2021
@fujiwarat fujiwarat added this to the 1.5.26 milestone Nov 4, 2021
@fujiwarat
Copy link
Member

Thank you for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants