Serhiy Storchaka added the comment:
print() converts all its arguments to string by calling str(). The resulting
strings are written to the output file.
print(bin_buff, file=fp) is equivalent to
fp.write(str(bin_buff))
fp.write('\n')
If you will run Python with options -b or -bb you
New submission from jeff deifik :
I am running python 3.6.3 on cygwin / windows.
Here is a test program to demonstrate the bug:
#!/usr/bin/env python3
fp = open("bug_out.txt", "ab")
buff = 'Hello world'
print('type of buff is', type(buff))
bin_buff = bytes(buff, 'utf-8')
print('type of bin_bu