Commit 42c35d9c authored by Serhiy Storchaka's avatar Serhiy Storchaka Committed by GitHub

bpo-31966: Fixed WindowsConsoleIO.write() for writing empty data. (GH-5754)

parent aef1283b
......@@ -121,6 +121,10 @@ class WindowsConsoleIOTests(unittest.TestCase):
else:
self.assertNotIsInstance(f, ConIO)
def test_write_empty_data(self):
with ConIO('CONOUT$', 'w') as f:
self.assertEqual(f.write(b''), 0)
def assertStdinRoundTrip(self, text):
stdin = open('CONIN$', 'r')
old_stdin = sys.stdin
......
Fixed WindowsConsoleIO.write() for writing empty data.
......@@ -964,6 +964,9 @@ _io__WindowsConsoleIO_write_impl(winconsoleio *self, Py_buffer *b)
if (!self->writable)
return err_mode("writing");
if (!b->len) {
return PyLong_FromLong(0);
}
if (b->len > BUFMAX)
len = BUFMAX;
else
......
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