Issue
What were you trying to do that didn't work?
`rct cat-cert` in specific `LC` raises uncaught `UnicodeEncodeError`. The exception comes from `gettext` library.
Please provide the package NVR for which bug is seen:
`gettext-0.19.8.1-17.el8.x86_64`
(not present in `gettext-0.21-7.el9.x86_64`)
How reproducible:
100%
Steps to reproduce
Have `subscription-manager` installed on RHEL8.
`LC_ALL=C LANG=ja_JP.UTF-8 rct cat-cert --no-content /etc/pki/product-default/479.pem`
`echo -e "from subscription_manager.i18n import ugettext as , configure_i18n\nconfigure_i18n()\nprint(('Product Certificate'))" | LC_ALL=C LANG=ja_JP.UTF-8 python3`
Expected results
2. prints certificate details in Japan
3. prints "製品証明書" ("Product Certificate" in Japan)
Actual results
2. raises exception:
Traceback (most recent call last):
File "/usr/bin/rct", line 11, in <module>
load_entry_point('subscription-manager==1.28.36', 'console_scripts', 'rct')()
File "/usr/lib64/python3.6/site-packages/subscription_manager/scripts/rct.py", line 40, in main
return RctCLI().main()
File "/usr/lib64/python3.6/site-packages/subscription_manager/cli.py", line 192, in main
return cmd.main()
File "/usr/lib64/python3.6/site-packages/rct/commands.py", line 39, in main
return_code = self._do_command()
File "/usr/lib64/python3.6/site-packages/rct/cert_commands.py", line 76, in _do_command
skip_products=self.options.no_products)
File "/usr/lib64/python3.6/site-packages/rct/printing.py", line 268, in printc
printer.printc(cert)
File "/usr/lib64/python3.6/site-packages/rct/printing.py", line 142, in printc
print(self.cert_to_str(cert))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 48-52: ordinal not in range(128)
3. raises exception:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
Note the `LC_ALL=C` that is crucial for the reproducer.
Some debugging of the code revealed that `/usr/lib64/python3.6/gettext.py` line 445:
def gettext(self, message):
missing = object()
tmsg = self._catalog.get(message, missing)
if tmsg is missing:
already sets `tmsg` to some "unprintable" list of characters.