mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
[PR #71] [MERGED] [python] fix unbuffered binary mode for I/O streams in Windows pypy #664
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/google/brotli/pull/71
Author: @anthrotype
Created: 4/16/2015
Status: ✅ Merged
Merged: 4/16/2015
Merged by: @szabadka
Base:
master← Head:pypy_unbuffered📝 Commits (1)
b316cb7[python] fix unbuffered binary mode for I/O streams in Windows pypy📊 Changes
1 file changed (+10 additions, -2 deletions)
View changed files
📝
python/bro.py(+10 -2)📄 Description
Hello,
I tried to build the brotli extension under PyPy and everything seems fine.
I tested the latest Python2.7-compatible release (PyPy version 2.5.1) on OS X, Ubuntu and Windows.
The extension compiles correctly, and both the compatibility and roundtrip tests pass just like with the CPython implementation.
I only found a small issue when running tests under pypy for Windows. It has to do with the "bro.py" script used for the tests. In PyPy, the
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARYtrick does not seem to produce any effect (unlike under Windows CPython), and so brotli fails because the standard input/output streams are not read/written in binary mode, but in the default text mode (with\nline endings converted to\r\n).I modified the "bro.py" script to use a different method (
os.fdopen) to reopen standard streams in binary mode only when it is run from PyPy on Windows. For some reasons, the latter trick does not work from Windows CPython, so for the latter I still use themsvcrt.setmodemethod.Cheers,
Cosimo
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.