summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/io.c b/io.c
index ad0cb3f7a..30e407f5d 100644
--- a/io.c
+++ b/io.c
@@ -4506,6 +4506,12 @@ rb_open_file(int argc, VALUE *argv, VALUE io)
fmode = NIL_P(perm) ? 0666 : NUM2UINT(perm);
rb_file_sysopen_internal(io, RSTRING_PTR(fname), flags, fmode);
+
+ if (!FIXNUM_P(vmode)) {
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ rb_io_mode_enc(fptr, StringValueCStr(vmode));
+ }
}
else {
mode = NIL_P(vmode) ? "r" : StringValueCStr(vmode);