Strip whitespaces added by decode() function

This commit is contained in:
Azim Khan 2018-06-28 16:47:12 +01:00 committed by Mohammad Azim Khan
parent 00c4b090c1
commit 936ea9302a

View file

@ -97,8 +97,9 @@ class FileWrapper(io.FileIO):
line = parent.next() # Python 2
if line:
self.line_no += 1
# Convert byte array to string with correct encoding
return line.decode(sys.getdefaultencoding())
# Convert byte array to string with correct encoding and
# strip any whitespaces added in the decoding process.
return line.decode(sys.getdefaultencoding()).strip() + "\n"
return None
next = __next__