Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/tk/tkutil/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
begin
require 'mkmf'

have_func("rb_eval_cmd_kw", "ruby.h")
have_func("rb_obj_instance_exec", "ruby.h")
have_func("rb_sym2str", "ruby.h")
have_func("rb_id2str", "ruby.h")
Expand Down
12 changes: 12 additions & 0 deletions ext/tk/tkutil/tkutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,19 @@ tk_eval_cmd(int argc, VALUE *argv, VALUE self)

rb_scan_args(argc, argv, "1*", &cmd, &rest);
#ifdef RB_PASS_KEYWORDS
# ifdef HAVE_RB_EVAL_CMD_KW
return rb_eval_cmd_kw(cmd, rest, 0);
# else
if (RB_TYPE_P(cmd, T_STRING)) {
VALUE val = rb_funcallv_kw(rb_const_get(rb_cObject, rb_intern("TOPLEVEL_BINDING")), rb_intern("eval"), 1, &cmd, 0);
RB_GC_GUARD(cmd);
return val;
} else {
VALUE val = rb_funcallv_kw(cmd, rb_intern("call"), RARRAY_LENINT(rest), RARRAY_CONST_PTR(rest), 0);
RB_GC_GUARD(rest);
return val;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rb_eval_cmd_kw() in https://github.com/ruby/ruby/blob/941e70ab38d01d067b7bbbcdf8553893a9ca8b49/vm_eval.c#L2148-L2179 doesn't suppress exceptions. The rb_protect() around the eval and funcall should be unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I misunderstood the purpose of the tag code in rb_eval_cmd_call_kw when trying to recreate the behavior. I'll update the PR.

# endif
#else
return rb_eval_cmd(cmd, rest, 0);
#endif
Expand Down