Bug 614767
Summary: | encoding problems | ||
---|---|---|---|
Product: | [Fedora] Fedora EPEL | Reporter: | Florian La Roche <florian.laroche> |
Component: | koji | Assignee: | Dennis Gilmore <dennis> |
Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | el6 | CC: | a.badger, dcantrell, mikem |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2017-02-21 16:16:38 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Florian La Roche
2010-07-15 08:17:33 UTC
Another fix suggestion for this problem from Toshio: http://lists.fedoraproject.org/pipermail/buildsys/2010-August/003223.html regards, Florian La Roche As Florian suggests, using fixEncoding() for that section of code and changing how fixEncoding works is probably the best outcome. Here's my revised fixEncoding():: import warnings def fixEncoding(value, from_encoding=None, fallback=None): # fallback is used for backwards compatibility if not from_encoding: if fallback: warnings.warn('fixEncoding() no longer takes a fallback' ' keyword arg. Use from_encoding instead.', DeprecationWarning, stacklevel=2) from_encoding = fallback else: from_encoding = 'utf8' if isinstance(value, unicode): # value is already unicode, so just convert it # to a utf8-encoded str # Note: with python3, this can fail unless you use an error # argument because a unicode string could have been created using # the surrogateescape error handler. return value.encode('utf8', 'replace') else: # value is a str but may not be valid utf8 (encoded in latin1, for # instance). Note that the string is almost certain to be mangled # in these instances unless you know what encoding the string is in # and have set from_encoding to that encoding. return value.decode(from_encoding, 'replace').encode('utf8', 'replace') Note that there's three separate issues with varying severity: 1) UnicodeError known to be thrown for certain notifications. Florian's fix in this bug's description will solve that. 2) Potential for UnicodeError to be thrown with empty strings. Removing ``if not value: return value`` from fixEncoding() will fix that. 3) Cosmetically and for debugability, using replacement characters instead of characters from a hardcoded charset is better. My fixEncoding() will fix that. closing this bug, if issues still persist then please reopen it |