[issue32520] error writing to file in binary mode - python 3.6.3

2018-01-08 Thread Serhiy Storchaka
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

[issue32520] error writing to file in binary mode - python 3.6.3

2018-01-08 Thread jeff deifik
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')