Bug #15322
closedpython3.11 removed codeset from gettext.install()
100%
Description
The codeset
parameter of gettext.install()
was deprecated in Python 3.8 and finally removed in version 3.11.
This parameter is still used in usr/src/tools/scripts/validate_pkg.py
and so it does not run with python 3.11
It's possible to build gate with python 3.11 after #15208 but doing a build using version 3.11 as the primary python version fails at the packaging phase with:
.../opt/onbld/bin/validate_pkg", line 894, in <module> gettext.install("pkg", "/usr/share/locale", TypeError: install() got an unexpected keyword argument 'codeset' dmake: Warning: Target `pmodes' not remade because of errors
Related issues
Updated by Andy Fiddaman 5 months ago
- Related to Feature #15208: Allow building with python 3.11 added
Updated by Andy Fiddaman 5 months ago
From the python 3.8 "What's new" document:
The following functions and methods are deprecated in the gettext module: lgettext(), ldgettext(), lngettext() and ldngettext(). They return encoded bytes, and it’s possible that you will get unexpected Unicode-related exceptions if there are encoding problems with the translated strings. It’s much better to use alternatives which return Unicode strings in Python 3. These functions have been broken for a long time.
Function bind_textdomain_codeset(), methods output_charset() and set_output_charset(), and the codeset parameter of functions translation() and install() are also deprecated, since they are only used for the l*gettext() functions.
It appears it was always a nop to pass codeset
to gettext.install()
and so we should be able to just safely remove this and have the resulting program work on all python versions, including 3.11
Updated by Andy Fiddaman 5 months ago
I've done two illumos-gate builds with the patch in the associated gerrit review:
export BUILDPY2='#' export BUILDPY3= export BUILDPY2TOOLS='#' export BUILDPY3TOOLS= export PYTHON3_VERSION=3.10 export PYTHON3_PKGVERS=-310 export PYTHON3_SUFFIX= export TOOLS_PYTHON=/usr/bin/python$PYTHON3_VERSION
and
export BUILDPY2='#' export BUILDPY3= export BUILDPY2TOOLS='#' export BUILDPY3TOOLS= export PYTHON3_VERSION=3.11 export PYTHON3_PKGVERS=-311 export PYTHON3_SUFFIX= export TOOLS_PYTHON=/usr/bin/python$PYTHON3_VERSION
Both were successful.
Updated by Electric Monk 5 months ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
git commit cce0d68b020e5b887083e543f5638759fa3dca86
commit cce0d68b020e5b887083e543f5638759fa3dca86 Author: Andy Fiddaman <illumos@fiddaman.net> Date: 2023-01-16T20:01:03.000Z 15322 python3.11 removed codeset from gettext.install() Reviewed by: Yuri Pankov <yuri@aetern.org> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Dan McDonald <danmcd@mnx.io>