This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lopgok
Recipients lopgok
Date 2018-01-08.15:55:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1515426931.81.0.467229070634.issue32520@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-01-08 15:55:31lopgoksetrecipients: + lopgok
2018-01-08 15:55:31lopgoksetmessageid: <1515426931.81.0.467229070634.issue32520@psf.upfronthosting.co.za>
2018-01-08 15:55:31lopgoklinkissue32520 messages
2018-01-08 15:55:31lopgokcreate