From d8562ab2a40658db0e6a44ce07cfbe616b9b4078 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 28 Nov 2016 14:22:12 -0800 Subject: Passing `binmode: true` to `IO.pipe` should behave like `binmode` When passing `binmode: true` to `IO.pipe`, it should behave the same way as calling `binmode` on each of the file handles. It should set the file to binmode *and* set the encoding to binary on the file. Before this commit, passing `binmode: true` to `IO.pipe` would make `binmode?` return `true`, but the file's encoding would remain the same as the default encoding. Passing `binmode: true` should make `binmode?` return `true` *and* set the encoding to binary. --- io.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'io.c') diff --git a/io.c b/io.c index f78c09ba40..00d3716839 100644 --- a/io.c +++ b/io.c @@ -10312,6 +10312,12 @@ rb_io_s_pipe(int argc, VALUE *argv, VALUE klass) rb_io_synchronized(fptr2); extract_binmode(opt, &fmode); + + if (fmode & FMODE_BINMODE) { + rb_io_ascii8bit_binmode(r); + rb_io_ascii8bit_binmode(w); + } + #if DEFAULT_TEXTMODE if ((fptr->mode & FMODE_TEXTMODE) && (fmode & FMODE_BINMODE)) { fptr->mode &= ~FMODE_TEXTMODE; -- cgit v1.2.3