New submission from jeff deifik <j...@jeffunit.com>: 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_buff is', type(bin_buff)) print(bin_buff, file=fp) Here is the output: ./bug.py type of buff is <class 'str'> type of bin_buff is <class 'bytes'> Traceback (most recent call last): File "./bug.py", line 8, in <module> print(bin_buff, file=fp) TypeError: a bytes-like object is required, not 'str' The python type system things bin_buff has type bytes, but when I try to print it, the print function thinks it is of type str. ---------- components: IO messages: 309669 nosy: lopgok priority: normal severity: normal status: open title: error writing to file in binary mode - python 3.6.3 versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32520> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com