@@ -191,6 +191,14 @@ static VALUE kernel_spec_rb_protect_yield(VALUE self, VALUE obj, VALUE ary) {
191
191
return res ;
192
192
}
193
193
194
+ static VALUE kernel_spec_rb_protect_errinfo (VALUE self , VALUE obj , VALUE ary ) {
195
+ int status = 0 ;
196
+ VALUE res = rb_protect (rb_yield , obj , & status );
197
+ rb_ary_store (ary , 0 , INT2NUM (23 ));
198
+ rb_ary_store (ary , 1 , res );
199
+ return rb_errinfo ();
200
+ }
201
+
194
202
static VALUE kernel_spec_rb_protect_null_status (VALUE self , VALUE obj ) {
195
203
return rb_protect (rb_yield , obj , NULL );
196
204
}
@@ -345,6 +353,7 @@ void Init_kernel_spec(void) {
345
353
rb_define_method (cls , "rb_rescue" , kernel_spec_rb_rescue , 4 );
346
354
rb_define_method (cls , "rb_rescue2" , kernel_spec_rb_rescue2 , -1 );
347
355
rb_define_method (cls , "rb_protect_yield" , kernel_spec_rb_protect_yield , 2 );
356
+ rb_define_method (cls , "rb_protect_errinfo" , kernel_spec_rb_protect_errinfo , 2 );
348
357
rb_define_method (cls , "rb_protect_null_status" , kernel_spec_rb_protect_null_status , 1 );
349
358
rb_define_method (cls , "rb_eval_string_protect" , kernel_spec_rb_eval_string_protect , 2 );
350
359
rb_define_method (cls , "rb_catch" , kernel_spec_rb_catch , 2 );
0 commit comments