Skip to content

fix unwanted CRLF conversion on windows#11

Open
erik-smit wants to merge 1 commit into
Lekensteyn:masterfrom
erik-smit:master
Open

fix unwanted CRLF conversion on windows#11
erik-smit wants to merge 1 commit into
Lekensteyn:masterfrom
erik-smit:master

Conversation

@erik-smit

Copy link
Copy Markdown

python 2.x does CRLF conversion on windows by default, causing my READs to be damaged.

Took my fix from http://stackoverflow.com/questions/2374427/python-2-x-write-binary-output-to-stdout

@ehem ehem left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ick! Alas, looking at documentation I can see why you want to do this. :-(

First, any additions should be moved to the except clause. Using sys.stdout.buffer takes care of this in a portable way for Python 3, so something like this is only needed if the try fails (indicating Python 2).

Does:
stdout_bin = os.fdopen(os.dup(1), "wb")
in the except clause get you binary output with Python 2 on Windows? When looking for alternatives I read os.fdopen(1, "wb") doesn't work, but perhaps this is sufficient to not get optimized out by Python 2.

@Lekensteyn

Copy link
Copy Markdown
Owner

@erik-smit Thanks for your PR! Does this also work with Python 3? Can you try the suggestion from @ehem?

@erik-smit

Copy link
Copy Markdown
Author

I don't really have time to further this, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants