diff --git a/binding-mri/binding-util.h b/binding-mri/binding-util.h index 743da529..bed2a606 100644 --- a/binding-mri/binding-util.h +++ b/binding-mri/binding-util.h @@ -394,7 +394,7 @@ static inline VALUE rb_file_open_str(VALUE filename, const char *mode) { VALUE fileobj = rb_const_get(rb_cObject, rb_intern("File")); - return rb_funcall(fileobj, rb_intern("open"), 2, filename, mode); + return rb_funcall(fileobj, rb_intern("open"), 2, filename, rb_str_new2(mode)); } #endif diff --git a/binding-mri/filesystem-binding.cpp b/binding-mri/filesystem-binding.cpp index c15705b4..41163d44 100644 --- a/binding-mri/filesystem-binding.cpp +++ b/binding-mri/filesystem-binding.cpp @@ -132,8 +132,15 @@ VALUE kernelLoadDataInt(const char *filename, bool rubyExc) { rb_gc_start(); - + +#ifndef OLD_RUBY VALUE port = fileIntForPath(filename, rubyExc); +#else + // the above results in an uninitialized IO, + // so let's use Ruby to open the file instead + // hopefully a temporary fix + VALUE port = rb_file_open_str(rb_str_new2(filename), "rb"); +#endif VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));