From ac84c2aee2c576247e7961491904f909e8b9ab66 Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 16 Feb 2018 15:27:37 +0000 Subject: merge revision(s) 58471,58493: [Backport #13505] load.c: backtrace of circular require * load.c (load_lock): print backtrace of circular require via `Warning.warn` [ruby-core:80850] [Bug #13505] Send the backtrace of the circular require warning as a single String to Warning.warn * load.c: send as a single string. * error.c: expose the string formatted by rb_warning as rb_warning_string(). * test/ruby/test_exception.rb: update tests. [ruby-core:80850] [Bug #13505] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- error.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'error.c') diff --git a/error.c b/error.c index b890be13a8..ee805d4cc1 100644 --- a/error.c +++ b/error.c @@ -162,10 +162,16 @@ rb_warning_s_warn(VALUE mod, VALUE str) return Qnil; } +VALUE +rb_warning_warn(VALUE mod, VALUE str) +{ + return rb_funcallv(mod, id_warn, 1, &str); +} + static void rb_write_warning_str(VALUE str) { - rb_funcall(rb_mWarning, id_warn, 1, str); + rb_warning_warn(rb_mWarning, str); } static VALUE @@ -254,6 +260,14 @@ rb_warning(const char *fmt, ...) } } +VALUE +rb_warning_string(const char *fmt, ...) +{ + with_warning_string(mesg, 0, fmt) { + } + return mesg; +} + #if 0 void rb_enc_warning(rb_encoding *enc, const char *fmt, ...) -- cgit v1.2.3