#4214 Fix for reading config files when contains UTF-8 chars
Merged by tkopecek. Opened by jcupova.
jcupova/koji issue-4191  into  master

Download 4214.patch

Fixes: https://pagure.io/koji/issue/4191

Python 3 has utf-8 as a default encoding, so it is worth to add a comment why it is needed here. I assume that it is because that it is not working in case when there is C locale enabled? In such case it would turn to encoding='locale' thus using ascii instead of utf-8.

:thumbsup:

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

Also, some testing configs would be valuable here.

Dropping testing-ready, currently merge conflict with another testing-ready PR.

Metadata Update from @jcupova:
- Pull-request untagged with: testing-ready

Before we go about making these changes, do we have a replicator for #4191 ?

A casual attempt to replicate the complaint ("comment in the config files contains an unicode character"), does not seem to hit an error with the original code.

Metadata Update from @jcupova:
- Pull-request tagged with: testing-ready

Metadata Update from @jcupova:
- Pull-request untagged with: testing-ready

Metadata Update from @mfilip:
- Pull-request tagged with: testing-ready

rebased onto ad221feb8ba808bcb5bc8e265d513f689d838bc6

I've replicated it with such comment in web.conf:

# comment ěščřčž
[web]
SiteName = koji
KojiHubURL = http://koji-hub/kojihub
KojiFilesURL = http://localhost:8080/kojifiles
...

I've replicated it with such comment in web.conf:

I'm still unable to do so. What platform? What locale?

Can you replicate it with a plain call to config.read?

I've tried to make a unit test that manifests this and so far I have failed. The situation is complicated by the various places that we adjust locale in the unit tests without resetting it (and the the difficulty in sanely doing such a reset).

Ok, finally got it. almalinuxorg/8-base container. This hits it

import koji
import locale
locale.setlocale(locale.LC_ALL, 'C')
cfg = koji.read_config_files('test.cfg')

I thought I'd tried this permutation before. I must have done something odd.

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

additional unit test here -- https://pagure.io/fork/mikem/koji/commits/pr4214updates
(fails on rhel8 if I revert the fix)

1 new commit added

  • add unit test

Commit 0a7e76d9 fixes this pull-request

Pull-Request has been merged by tkopecek

Metadata