openSUSE / openSUSE/obs-service-replace_using_package_version
UnicodeDecodeError: 'ascii' codec can't decode byte
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with /usr/lib/obs/service/replace_using_package_version, especially main() and apply_regex_to_file() around the lines shown in the traceback. Reproduce the failure using replacement text containing an em dash or curly apostrophe, then confirm the service processes the file without the reported UnicodeDecodeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100