Commit 04d666cd authored by Jason Madden's avatar Jason Madden Committed by GitHub

Merge pull request #1286 from gevent/issue1282

Fix #1282 by patching libuv
parents d221b203 ba2223eb
...@@ -9,9 +9,14 @@ ...@@ -9,9 +9,14 @@
- Formatting run info no longer includes ``gevent.local.local`` - Formatting run info no longer includes ``gevent.local.local``
objects that have no value in the greenlet. See :issue:`1275`. objects that have no value in the greenlet. See :issue:`1275`.
- Fixed negative length in pywsgi's Input read functions for non chunked body. - Fixed negative length in pywsgi's Input read functions for non chunked body.
Reported in :issue:`1274` by tzickel. Reported in :issue:`1274` by tzickel.
- Upgrabe libuv from 1.22.0 to 1.23.2.
- Upgrade libuv from 1.22.0 to 1.23.2.
- Fix opening files in text mode in CPython 2 on Windows by patching
libuv. See :issue:`1282` reported by wiggin15.
1.3.6 (2018-08-17) 1.3.6 (2018-08-17)
================== ==================
......
...@@ -19,3 +19,6 @@ Updating libuv ...@@ -19,3 +19,6 @@ Updating libuv
- rm -rf libuv/test - rm -rf libuv/test
- rm -rf libuv/tools - rm -rf libuv/tools
- rm -f libuv/android-configure* - rm -f libuv/android-configure*
- Apply the patches to libuv:
- git apply libuv-win-binary.patch
diff --git a/deps/libuv/src/win/fs.c b/deps/libuv/src/win/fs.c
index 812c1a6d..f4d66628 100644
--- a/deps/libuv/src/win/fs.c
+++ b/deps/libuv/src/win/fs.c
@@ -135,7 +135,14 @@ const WCHAR UNC_PATH_PREFIX_LEN = 8;
static int uv__file_symlink_usermode_flag = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
void uv_fs_init(void) {
- _fmode = _O_BINARY;
+/* gevent: This breaks `open()` on CPython 2 by changing
+ * the default mode for file operations. Python 3 and PyPy
+ * ar unaffected. It was removed for the (unreleased) libuv 2.
+ * See https://github.com/gevent/gevent/issues/1282
+ */
+/*
+ * _fmode = _O_BINARY;
+ */
}
...@@ -135,7 +135,14 @@ const WCHAR UNC_PATH_PREFIX_LEN = 8; ...@@ -135,7 +135,14 @@ const WCHAR UNC_PATH_PREFIX_LEN = 8;
static int uv__file_symlink_usermode_flag = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; static int uv__file_symlink_usermode_flag = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
void uv_fs_init(void) { void uv_fs_init(void) {
_fmode = _O_BINARY; /* gevent: This breaks `open()` on CPython 2 by changing
* the default mode for file operations. Python 3 and PyPy
* ar unaffected. It was removed for the (unreleased) libuv 2.
* See https://github.com/gevent/gevent/issues/1282
*/
/*
* _fmode = _O_BINARY;
*/
} }
......
...@@ -62,15 +62,6 @@ if sys.platform == 'win32': ...@@ -62,15 +62,6 @@ if sys.platform == 'win32':
# This one sometimes randomly closes connections, but no indication # This one sometimes randomly closes connections, but no indication
# of a server crash, only a client side close. # of a server crash, only a client side close.
'FLAKY test__server_pywsgi.py', 'FLAKY test__server_pywsgi.py',
# We only use FileObjectThread on Win32. Sometimes the
# visibility of the 'close' operation, which happens in a
# background thread, doesn't make it to the foreground
# thread in a timely fashion, leading to 'os.close(4) must
# not succeed' in test_del_close. We have the same thing
# with flushing and closing in test_newlines. Both of
# these are most commonly (only?) observed on Py27/64-bit.
# They also appear on 64-bit 3.6 with libuv
'FLAKY test__fileobject.py',
] ]
if PYPY and LIBUV: if PYPY and LIBUV:
......
...@@ -3,6 +3,7 @@ import os ...@@ -3,6 +3,7 @@ import os
import sys import sys
import tempfile import tempfile
import gc import gc
import unittest
import gevent import gevent
from gevent.fileobject import FileObject, FileObjectThread from gevent.fileobject import FileObject, FileObjectThread
...@@ -11,6 +12,7 @@ import greentest ...@@ -11,6 +12,7 @@ import greentest
from greentest.sysinfo import PY3 from greentest.sysinfo import PY3
from greentest.flaky import reraiseFlakyTestRaceConditionLibuv from greentest.flaky import reraiseFlakyTestRaceConditionLibuv
from greentest.skipping import skipOnLibuvOnCIOnPyPy from greentest.skipping import skipOnLibuvOnCIOnPyPy
from greentest.skipping import skipOnWindows
try: try:
ResourceWarning ResourceWarning
...@@ -61,10 +63,20 @@ class Test(greentest.TestCase): ...@@ -61,10 +63,20 @@ class Test(greentest.TestCase):
with FileObject(r, 'rb') as fobj: with FileObject(r, 'rb') as fobj:
self.assertEqual(fobj.read(), b'x') self.assertEqual(fobj.read(), b'x')
# We only use FileObjectThread on Win32. Sometimes the
# visibility of the 'close' operation, which happens in a
# background thread, doesn't make it to the foreground
# thread in a timely fashion, leading to 'os.close(4) must
# not succeed' in test_del_close. We have the same thing
# with flushing and closing in test_newlines. Both of
# these are most commonly (only?) observed on Py27/64-bit.
# They also appear on 64-bit 3.6 with libuv
@skipOnWindows("Thread race conditions")
def test_del(self): def test_del(self):
# Close should be true by default # Close should be true by default
self._test_del() self._test_del()
@skipOnWindows("Thread race conditions")
def test_del_close(self): def test_del_close(self):
self._test_del(close=True) self._test_del(close=True)
...@@ -172,5 +184,29 @@ def writer(fobj, line): ...@@ -172,5 +184,29 @@ def writer(fobj, line):
fobj.close() fobj.close()
class TestTextMode(unittest.TestCase):
def test_default_mode_writes_linesep(self):
# See https://github.com/gevent/gevent/issues/1282
# libuv 1.x interferes with the default line mode on
# Windows.
# First, make sure we initialize gevent
gevent.get_hub()
fileno, path = tempfile.mkstemp('.gevent.test__fileobject.test_default')
self.addCleanup(os.remove, path)
os.close(fileno)
with open(path, "w") as f:
f.write("\n")
with open(path, "rb") as f:
data = f.read()
self.assertEqual(data, os.linesep.encode('ascii'))
if __name__ == '__main__': if __name__ == '__main__':
greentest.main() greentest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment