openSUSE / obs-service-replace_using_package_version

An OBS service to replace a regex with some package version available in the build time repositories
GNU General Public License v3.0
4 stars 12 forks source link

UnicodeDecodeError: 'ascii' codec can't decode byte #66

Open alexandrevicenzi opened 2 months ago

alexandrevicenzi commented 2 months ago

The script fails if the text to be replaced contains non-ascii or UTF-8 characters.

For example, the following symbol will cause:

[   35s] Traceback (most recent call last):
[   35s]   File "/usr/lib/obs/service/replace_using_package_version", line 186, in <module>
[   35s]     init(__name__)
[   35s]   File "/usr/lib/obs/service/replace_using_package_version", line 183, in init
[   35s]     main()
[   35s]   File "/usr/lib/obs/service/replace_using_package_version", line 99, in main
[   35s]     replacement
[   35s]   File "/usr/lib/obs/service/replace_using_package_version", line 105, in apply_regex_to_file
[   35s]     contents = in_file.read()
[   35s]   File "/usr/lib64/python3.6/encodings/ascii.py", line 26, in decode
[   35s]     return codecs.ascii_decode(input, self.errors)[0]
[   35s] UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 3615: ordinal not in range(128)
[   35s] service run failed for service 'replace_using_package_version'

is not -, but it is commonly used to split a sentence. is not ', but it can be a hard-to-spot typo and also causes the script to fail.

dcermak commented 2 months ago

Can you please share a full reproducer of this bug, if you have one?

dcermak commented 2 months ago

It appears that you are running an older version of the package, could you please use osc buildinfo to figure out which version it is?

alexandrevicenzi commented 2 months ago

The issue has been caught in the BCI project in OBS, it seems to fail in SLE only, not in Factory.

In SP6 the package version is: obs-service-replace_using_package_version-0.0.3-3.6.1 In Tumbleweed the package version is: obs-service-replace_using_package_version-0.0.9-1.3

A reproducer can be found here: https://build.opensuse.org/package/show/home:avicenzi/replace_using_package_version

dcermak commented 2 months ago

Alexandre Vicenzi @.***> writes:

The issue has been caught in the BCI project in OBS, it seems to fail in SLE only, not in Factory.

In SP6 the package version is: obs-service-replace_using_package_version-0.0.3-3.6.1 In Tumbleweed the package version is: obs-service-replace_using_package_version-0.0.9-1.3

A reproducer can be found here: https://build.opensuse.org/package/show/home:avicenzi/replace_using_package_version

I have submitted https://build.suse.de/request/show/332647 to fix this

dcermak commented 1 week ago

This should have been fixed, can you please recheck @alexandrevicenzi?

alexandrevicenzi commented 2 days ago

@dcermak the reproducer I have in OBS still fails, once that works I would consider fixed.