-
Notifications
You must be signed in to change notification settings - Fork 196
Description
Following from #2190. Even if Python2 support is dropped, this could still do with a little tweaking to account for the fact that it's possible for a command to be placing non-text data (not just e.g. accented characters, but even binary data) on stdout in particular, and such data should ideally not be decoded until the point at which an attempt to display it as text is made.
-
When using
-infoor-debug,stderris currently split between terminal output that is decoded, and return value that is not; this should remain as-is. -
For
stdoutin this case, as well as bothstdout/stderrwhen neither-infonor-debugis used, text decoding should not occur. -
stdoutandstderrdata are accessible through two means: theCommandReturnnamedtupleand theMRtrixCmdErrorexception. Each of these would need to provide access to both the raw undecoded binary data, and decoded data in string form:-
For
CommandReturn, any alteration to the.stdoutand.stderrmembers would result in backward-incompatibility. One option to avoid this would be to keep those members as providing the decoded data, and have separate members of thenamedtupleproviding the undecoded data. But this may result in divergence with the behaviour ofMRtrixCmdErrordepending on what is done there... -
For
MRtrixCmdError, I'd need to check how may locations read from the individual.stdout/.stderrcontents, but if such usages are rare, the.__str__()member could perform decoding there instead of expecting those two members to be already decoded. That would also be consistent with how binary data vs. string data is intended to be handled in Python3 (as far as I can tell).
-