diff --git a/news/430.feature.rst b/news/430.feature.rst new file mode 100644 index 00000000..68a4fc1b --- /dev/null +++ b/news/430.feature.rst @@ -0,0 +1 @@ +Added an ``encoding`` attribute to ``ChannelFileWrite``. diff --git a/src/execnet/gateway_base.py b/src/execnet/gateway_base.py index 73dc7175..5048c45e 100644 --- a/src/execnet/gateway_base.py +++ b/src/execnet/gateway_base.py @@ -1079,6 +1079,8 @@ def __repr__(self) -> str: class ChannelFileWrite(ChannelFile): + encoding = "utf-8" + def write(self, out: bytes) -> None: self.channel.send(out) diff --git a/testing/test_channel.py b/testing/test_channel.py index d4712277..e6f9f7cf 100644 --- a/testing/test_channel.py +++ b/testing/test_channel.py @@ -327,6 +327,7 @@ def test_channel_file_write_error(self, gw: Gateway) -> None: channel = gw.remote_exec("pass") f = channel.makefile() assert not f.isatty() + assert f.encoding == "utf-8" channel.waitclose(TESTTIMEOUT) with pytest.raises(IOError): f.write(b"hello")