utils: run() handle unicode decode failure#132
utils: run() handle unicode decode failure#132dbungert wants to merge 2 commits intocanonical:mainfrom
Conversation
Expand the run() wrapper to handle logging and unicode decode failures in general. LP: #2011344
|
I'm a bit confused, does this change solve a problem or does it give more information to investigate? I wonder if we should not define a error handler to log the error and then call excerpt import codecs
def f(exc):
print("oops", exc)
return codecs.backslashreplace_errors(exc)
codecs.register_error('probert-run-unicode', f)
data = b'r\xe9serv\xe9e'
print(data.decode(errors='probert-run-unicode'))(we can pass the handler to subprocess directly) |
dumpe2fs is passing the latin1 string, which causes problems when we try to act on the non-label output. I'll incorporate your suggestion, which I think salvages the sizing information we are intrested in. |
The goal is a bit of both. Also, the goal is to log the reasons why the resize tool didn't succeed, so it shows that as well. |
| for line in stream.splitlines(): | ||
| for line in log_input.splitlines(): | ||
| log.debug(line) | ||
| return text |
There was a problem hiding this comment.
if we still return None here in case of UnicodeDecodeError, we don't solve the issue with the sizing information, do we?
Expand the run() wrapper to handle logging and unicode decode failures in general.
The original problem reports udev decode failures involving a NTFS partition with a label similar to 'NTFS réservée'. I am unable to construct that with NTFS, but a ext4 version was instructional. The subsequent dumpe2fs has invalid output.
Pyudev seems to handle this all well, I was unable to coax decode failures from it.
I think the robustness check is interesting for now, and if we get more info on reproduction steps, further work can be considered.
LP: #2011344