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: "python -u" not binary on cygwin
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: loewis Nosy List: jlt63, loewis, sjoerd
Priority: normal Keywords:

Created on 2002-06-17 13:56 by sjoerd, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
diff.txt sjoerd, 2002-06-17 13:56 fix for python -u not setting stdin/out in binary mode on cygwin
Messages (10)
msg11219 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2002-06-17 13:56
python -u is supposed to put sys.stdin and sys.stdout
in binary mode on systems where such things matter.
This does not happen on Window under Cygwin.

Try
python -u -c 'import sys;
open("x","wb").write(sys.stdin.read())' < some-text-file

and notice that the newly created file "x" has just \n
line endings instead of \r\n.

A patch is included.
msg11220 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2002-08-09 08:26
Logged In: YES 
user_id=43607

Assigned to Jason, since he seems to be the Cygwin expert. :-)
Does the patch make sense on other Cygwin installations than
my own?
msg11221 - (view) Author: Jason Tishler (jlt63) * (Python triager) Date: 2002-08-09 13:10
Logged In: YES 
user_id=86216

Martin,

This looks good.  Can I commit it?

Sjoerd,

> Does the patch make sense on other Cygwin
> installations than my own?

Yes, see below for the details.

My WAG is that you are using text mode mounts. Is
this correct? In my testing, I could only reproduce
this problem under text mode mounts -- never under
binary mode mounts.  Nevertheless, this patch
should be applied to guarantee proper behavior
regardless of the user's mount table.

Thanks for tracking down this issue and providing
a patch to fix it.

I wonder if there are any other binary vs. text
mode issues lurking...

BTW, the man page states the following:

-u     Force  stdin,  stdout  and  stderr  to  be
       totally unbuffered.

However, after reading the code, it is clear that
the "-u" option does more... :,)
msg11222 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-08-09 13:18
Logged In: YES 
user_id=21627

The patch is fine, please apply it. Also add a note to
python.man documenting that this changes the streams to
binary mode.
msg11223 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2002-08-09 13:26
Logged In: YES 
user_id=43607

If a execute the command "mount" it mentions "binmode" on
every line, so I guess that means I'm not using text mode.

I think the documentation should be extended to mention this
binary mode stuff, but that should be a separate bug report.
msg11224 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2002-08-09 13:38
Logged In: YES 
user_id=43607

I checked in the changes.
msg11225 - (view) Author: Jason Tishler (jlt63) * (Python triager) Date: 2002-08-09 14:24
Logged In: YES 
user_id=86216

> I checked in the changes.

Thanks!

> If a execute the command "mount" it mentions
> "binmode" on every line, so I guess that means
> I'm not using text mode.

What does "mount -p" indicate?  If textmode, was
your current working directory under the cygdrive
prefix?  If so, then we completely under this
issue. If not, then I'm at a loss to explain your
reported behavior.
msg11226 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2002-08-09 14:41
Logged In: YES 
user_id=43607

mount -p says
Prefix              Type         Flags
/cygdrive           system       binmode

Now that I look more carefully at the mount output, I see
that my current directory was mounted twice, once in
textmode and once in binmode.  To make a long story short,
the python I tried this on was running on textmode mount.

I guess we can close this now?
msg11227 - (view) Author: Jason Tishler (jlt63) * (Python triager) Date: 2002-08-09 15:03
Logged In: YES 
user_id=86216

> I guess we can close this now?

Yes.
msg11228 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2002-08-09 15:10
Logged In: YES 
user_id=43607

Closed this bug.
History
Date User Action Args
2022-04-10 16:05:25adminsetgithub: 36760
2002-06-17 13:56:52sjoerdcreate