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.

classification
Title: extra characters displayed when writing to sys.stdout.buffer
Type: behavior Stage:
Components: IO Versions: Python 3.1
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, metolone
Priority: normal Keywords:

Created on 2009-06-26 02:20 by metolone, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg89719 - (view) Author: Mark Tolonen (metolone) Date: 2009-06-26 02:20
According to Issue xxxx, sys.stdout.buffer is the binary stream 
underlying stdout.  I see the following behavior on 3.0.1 and 3.1rc2 
when writing to a console window:

Python 3.1rc2 (r31rc2:73414, Jun 13 2009, 16:43:15) [MSC v.1500 32 bit 
(Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> 
sys.stdout.buffer.write('hello\u200bworld'.encode('cp437','replace'))
hello?world11

Notice the extra '11' at the end of the string.
msg89720 - (view) Author: Mark Tolonen (metolone) Date: 2009-06-26 02:23
Sorry, msg.replace('Issue xxxx','Issue 4571').
msg89721 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-06-26 02:37
This is because write() is returning the number of characters it wrote
and that is displayed at the prompt.
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50594
2009-06-26 02:37:06benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg89721

resolution: works for me
2009-06-26 02:23:05metolonesetmessages: + msg89720
2009-06-26 02:20:27metolonecreate