Commit f6cf7deb authored by Jason Madden's avatar Jason Madden

I verified in a local VM that gevent's universal newline handling in...

I verified in a local VM that gevent's universal newline handling in subprocess matches the stdlibs (it's arguably broken). Update the tests for this case and mark them no longer failing
parent a9e71b54
...@@ -8,9 +8,8 @@ ...@@ -8,9 +8,8 @@
================== ==================
- Windows/Python 3: Port the :mod:`gevent.subprocess` module, fixing a - Windows/Python 3: Port the :mod:`gevent.subprocess` module, fixing a
large number of failing tests. Universal newline support, however, large number of failing tests. Examples of failures are in
still has some edge cases. Examples of failures are in :issue:`668` :issue:`668` and :issue:`669` srossross.
and :issue:`669` srossross.
1.1b6 (Oct 17, 2015) 1.1b6 (Oct 17, 2015)
==================== ====================
......
...@@ -440,8 +440,13 @@ class Popen(object): ...@@ -440,8 +440,13 @@ class Popen(object):
if PY3: if PY3:
# FileObjectThread doesn't support the 'U' qualifier # FileObjectThread doesn't support the 'U' qualifier
# with a bufsize of 0 # with a bufsize of 0
# XXX: Universal newlines seem broken on windows?
self.stdout = FileObject(c2pread, 'rb', bufsize) self.stdout = FileObject(c2pread, 'rb', bufsize)
# NOTE: Universal Newlines are broken on Windows/Py3, at least
# in some cases. This is true in the stdlib subprocess module
# as well; the following line would fix the test cases in
# test__subprocess.py that depend on python_universal_newlines,
# but would be inconsistent with the stdlib:
#msvcrt.setmode(self.stdout.fileno(), os.O_TEXT)
self.stdout.io = io.TextIOWrapper(self.stdout.io) self.stdout.io = io.TextIOWrapper(self.stdout.io)
self.stdout.io.mode = 'r' self.stdout.io.mode = 'r'
self.stdout._translate = True self.stdout._translate = True
......
...@@ -20,6 +20,13 @@ else: ...@@ -20,6 +20,13 @@ else:
python_universal_newlines = hasattr(sys.stdout, 'newlines') python_universal_newlines = hasattr(sys.stdout, 'newlines')
# The stdlib of Python 3 on Windows doesn't properly handle universal newlines
# (it produces broken results compared to Python 2)
# See gevent.subprocess for more details.
if PY3 and subprocess.mswindows:
python_universal_newlines_broken = True
else:
python_universal_newlines_broken = False
class Test(greentest.TestCase): class Test(greentest.TestCase):
...@@ -93,8 +100,13 @@ class Test(greentest.TestCase): ...@@ -93,8 +100,13 @@ class Test(greentest.TestCase):
stdout = p.stdout.read() stdout = p.stdout.read()
if python_universal_newlines: if python_universal_newlines:
# Interpreter with universal newline support # Interpreter with universal newline support
self.assertEqual(stdout, if not python_universal_newlines_broken:
"line1\nline2\nline3\nline4\nline5\nline6") self.assertEqual(stdout,
"line1\nline2\nline3\nline4\nline5\nline6")
else:
# Note the extra newline after line 3
self.assertEqual(stdout,
'line1\nline2\nline3\n\nline4\n\nline5\nline6')
else: else:
# Interpreter without universal newline support # Interpreter without universal newline support
self.assertEqual(stdout, self.assertEqual(stdout,
...@@ -121,8 +133,13 @@ class Test(greentest.TestCase): ...@@ -121,8 +133,13 @@ class Test(greentest.TestCase):
stdout = p.stdout.read() stdout = p.stdout.read()
if python_universal_newlines: if python_universal_newlines:
# Interpreter with universal newline support # Interpreter with universal newline support
self.assertEqual(stdout, if not python_universal_newlines_broken:
"line1\nline2\nline3\nline4\nline5\nline6") self.assertEqual(stdout,
"line1\nline2\nline3\nline4\nline5\nline6")
else:
# Note the extra newline after line 3
self.assertEqual(stdout,
'line1\nline2\nline3\n\nline4\n\nline5\nline6')
else: else:
# Interpreter without universal newline support # Interpreter without universal newline support
self.assertEqual(stdout, self.assertEqual(stdout,
......
...@@ -92,7 +92,6 @@ if sys.platform == 'win32': ...@@ -92,7 +92,6 @@ if sys.platform == 'win32':
if PY3: if PY3:
# XXX need investigating # XXX need investigating
FAILING_TESTS += [ FAILING_TESTS += [
'test__subprocess.py', # universal newlines are borked?
'FLAKY test__api_timeout.py', 'FLAKY test__api_timeout.py',
] ]
......
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