Author shamilbi
Recipients shamilbi, vinay.sajip
Date 2009-04-22.08:47:36
SpamBayes Score 6.07507e-09
Marked as misclassified No
Message-id <cd7fd19c0904220147g7665453dkdb5d61d5de33c189@mail.gmail.com>
In-reply-to <1240305907.01.0.510148893924.issue5170@psf.upfronthosting.co.za>
Content
>
> Trunk and release26-maint were recently changed (r71657, r71658) to use
> the following logic, which differs from the code snippet you posted.
>
>                    if (isinstance(msg, unicode) and
>                        getattr(stream, 'encoding', None)):
>                        stream.write(fs.decode(stream.encoding) % msg)
>                     else:
>                        stream.write(fs % msg)
>
> If the stream is stderr and you are passing a unicode msg, the else
> branch will not be taken; as long as the stream has an encoding
> attribute, it should output correctly.
>
> The change was made when another, similar issue was posted by another
> user (issue #5768).
>
> Can you confirm what happens with the current code as it is in
> release26-maint? спасибо!

it still doesn't work for console (but OK for files).

the following works in both cases:
if (isinstance(msg, unicode) and
    getattr(stream, 'encoding', None) and
    (stream == sys.stdout or stream == sys.stderr)):
    stream.write(fs % msg.encode(stream.encoding))
else:
     stream.write(fs % msg)

i think it's all about the difference betwin print(msg) and
sys.stdout.write('%s\n' % msg)

shamil
Files
File name Uploaded
unnamed shamilbi, 2009-04-22.08:47:36
History
Date User Action Args
2009-04-22 08:47:38shamilbisetrecipients: + shamilbi, vinay.sajip
2009-04-22 08:47:36shamilbilinkissue5170 messages
2009-04-22 08:47:36shamilbicreate