summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--error.c8
-rw-r--r--internal.h1
-rw-r--r--load.c5
-rw-r--r--test/ruby/test_exception.rb4
4 files changed, 14 insertions, 4 deletions
diff --git a/error.c b/error.c
index 709fcf3612..5c21229cbd 100644
--- a/error.c
+++ b/error.c
@@ -268,6 +268,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, ...)
diff --git a/internal.h b/internal.h
index 53f31b7804..cab6c8a545 100644
--- a/internal.h
+++ b/internal.h
@@ -1140,6 +1140,7 @@ NORETURN(void ruby_deprecated_internal_feature(const char *));
#define DEPRECATED_INTERNAL_FEATURE(func) \
(ruby_deprecated_internal_feature(func), UNREACHABLE)
VALUE rb_warning_warn(VALUE mod, VALUE str);
+VALUE rb_warning_string(const char *fmt, ...);
/* eval.c */
VALUE rb_refinement_module_get_refined_class(VALUE module);
diff --git a/load.c b/load.c
index 7d53b87eb3..1fddbf55cf 100644
--- a/load.c
+++ b/load.c
@@ -743,8 +743,9 @@ load_lock(const char *ftptr)
return (char *)"";
}
if (RTEST(ruby_verbose)) {
- rb_warning("loading in progress, circular require considered harmful - %s", ftptr);
- rb_backtrace_each(rb_warning_warn, rb_mWarning);
+ VALUE warning = rb_warning_string("loading in progress, circular require considered harmful - %s", ftptr);
+ rb_backtrace_each(rb_str_append, warning);
+ rb_warning_warn(rb_mWarning, warning);
}
switch (rb_thread_shield_wait((VALUE)data)) {
case Qfalse:
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index e53569c158..db13db76d6 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -1005,9 +1005,9 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
$LOAD_PATH.pop
$LOADED_FEATURES.delete(t)
end
+ assert_equal(1, warning.size)
assert_match(/circular require/, warning.first)
- warning.pop while %r[lib/rubygems/core_ext/kernel_require.rb:] =~ warning.last
- assert_operator(warning.last, :start_with?, "\tfrom #{path}:1:")
+ assert_match(/^\tfrom #{Regexp.escape(path)}:1:/, warning.first)
end
def test_undefined_backtrace