The assertion checks that the command output doesn't contain any null
bytes. I'm not sure if the intention was to make sure the string wasn't
shorter than the reported length or if this was a way to catch us
accidentally writing an (unformatted) null byte.
Regardless, the command output can be based on user input, so an
assertion doesn't make sense. For example, you should be totally allowed
to call print("\0") from Python. The latter doesn't trigger this bug
because it writes directly to the output stream and therefore bypasses
PrintCommandOutput but that's just an implementation detail.
I guess this could now be something like std::tie(line, str) = str.split('\n');