Another question looked at how to pipe byte strings to subprocess.Popen's to stdin when using unicode_literals. How to fix an encoding migrating Python subprocess to unicode_literals?. The answer there fixed the problem and created a warning when collecting the subprocess' stdout strings.
Still using:
from future import unicode_literals
Initially, I got the same UnicodeDecodeError error when collecting stdout. So! Using my new knowledge, I updated the receiving code that services stdout in a separate thread:
for text in iter(popen.stdout.readline,''):
text = text.decode(encoding)
text = text.strip(' \r\n')
This fixed the error, but a new warning appeared:
test.py:456: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
for text in iter(popen.stdout.readline,''):
With a little searching, I found I can suppress the warning message like this:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
for text in iter(popen.stdout.readline,''):
text = text.decode('utf-8')
text = text.strip(' \r\n')
QUESTION: Is there a way to resolve the mismatch or is suppressing the the best way to handle this?