Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not include a backtick in error messages and backtraces #9608

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
env:
RUBY_TESTOPTS: '-q --tty=no'
TESTS: ${{ matrix.test_task == 'check' && matrix.skipped_tests || '' }}
TEST_BUNDLED_GEMS_ALLOW_FAILURES: 'typeprof'
TEST_BUNDLED_GEMS_ALLOW_FAILURES: 'minitest,test-unit,debug,bigdecimal,drb,typeprof'
PRECHECK_BUNDLED_GEMS: 'no'

- name: make skipped tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
env:
RUBY_TESTOPTS: '-q --tty=no'
TESTS: ${{ matrix.test_task == 'check' && matrix.skipped_tests || '' }}
TEST_BUNDLED_GEMS_ALLOW_FAILURES: 'typeprof'
TEST_BUNDLED_GEMS_ALLOW_FAILURES: 'minitest,test-unit,debug,bigdecimal,drb,typeprof'
PRECHECK_BUNDLED_GEMS: 'no'

- name: make skipped tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yjit-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ jobs:
timeout-minutes: 60
env:
RUBY_TESTOPTS: '-q --tty=no'
TEST_BUNDLED_GEMS_ALLOW_FAILURES: 'typeprof'
TEST_BUNDLED_GEMS_ALLOW_FAILURES: 'minitest,test-unit,debug,bigdecimal,drb,typeprof'
PRECHECK_BUNDLED_GEMS: 'no'
SYNTAX_SUGGEST_TIMEOUT: '5'
YJIT_BINDGEN_DIFF_OPTS: '--exit-code'
Expand Down
12 changes: 6 additions & 6 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -4975,7 +4975,7 @@ big2str_generic(VALUE x, int base)
invalid_radix(base);

if (xn >= LONG_MAX/BITSPERDIG) {
rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
rb_raise(rb_eRangeError, "bignum too big to convert into 'string'");
}

power_level = 0;
Expand Down Expand Up @@ -5100,7 +5100,7 @@ rb_big2str1(VALUE x, int base)
invalid_radix(base);

if (xn >= LONG_MAX/BITSPERDIG) {
rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
rb_raise(rb_eRangeError, "bignum too big to convert into 'string'");
}

if (POW2_P(base)) {
Expand Down Expand Up @@ -5136,7 +5136,7 @@ big2ulong(VALUE x, const char *type)
if (len == 0)
return 0;
if (BIGSIZE(x) > sizeof(long)) {
rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
rb_raise(rb_eRangeError, "bignum too big to convert into '%s'", type);
}
ds = BDIGITS(x);
#if SIZEOF_LONG <= SIZEOF_BDIGIT
Expand Down Expand Up @@ -5179,7 +5179,7 @@ rb_big2long(VALUE x)
if (num <= 1+(unsigned long)(-(LONG_MIN+1)))
return -(long)(num-1)-1;
}
rb_raise(rb_eRangeError, "bignum too big to convert into `long'");
rb_raise(rb_eRangeError, "bignum too big to convert into 'long'");
}

#if HAVE_LONG_LONG
Expand All @@ -5197,7 +5197,7 @@ big2ull(VALUE x, const char *type)
if (len == 0)
return 0;
if (BIGSIZE(x) > SIZEOF_LONG_LONG)
rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
rb_raise(rb_eRangeError, "bignum too big to convert into '%s'", type);
#if SIZEOF_LONG_LONG <= SIZEOF_BDIGIT
num = (unsigned LONG_LONG)ds[0];
#else
Expand Down Expand Up @@ -5238,7 +5238,7 @@ rb_big2ll(VALUE x)
if (num <= 1+(unsigned LONG_LONG)(-(LLONG_MIN+1)))
return -(LONG_LONG)(num-1)-1;
}
rb_raise(rb_eRangeError, "bignum too big to convert into `long long'");
rb_raise(rb_eRangeError, "bignum too big to convert into 'long long'");
}

#endif /* HAVE_LONG_LONG */
Expand Down
2 changes: 1 addition & 1 deletion bootstraptest/test_exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def m
}

##
assert_match /undefined method `foo\'/, %q{#`
assert_match /undefined method 'foo\'/, %q{#`
STDERR.reopen(STDOUT)
class C
def inspect
Expand Down
6 changes: 3 additions & 3 deletions bootstraptest/test_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,9 @@ def assert_syntax_error expected, code, message = ''
assert_syntax_error "unterminated string meets end of file", '().."', '[ruby-dev:29732]'
assert_equal %q{[]}, %q{$&;[]}, '[ruby-dev:31068]'
assert_syntax_error "unexpected *, expecting '}'", %q{{*0}}, '[ruby-dev:31072]'
assert_syntax_error "`@0' is not allowed as an instance variable name", %q{@0..0}, '[ruby-dev:31095]'
assert_syntax_error "`$00' is not allowed as a global variable name", %q{$00..0}, '[ruby-dev:31100]'
assert_syntax_error "`$00' is not allowed as a global variable name", %q{0..$00=1}
assert_syntax_error "'@0' is not allowed as an instance variable name", %q{@0..0}, '[ruby-dev:31095]'
assert_syntax_error "'$00' is not allowed as a global variable name", %q{$00..0}, '[ruby-dev:31100]'
assert_syntax_error "'$00' is not allowed as a global variable name", %q{0..$00=1}
assert_equal %q{0}, %q{[*0];0}, '[ruby-dev:31102]'
assert_syntax_error "unexpected ')'", %q{v0,(*,v1,) = 0}, '[ruby-dev:31104]'
assert_equal %q{1}, %q{
Expand Down
6 changes: 3 additions & 3 deletions class.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ rb_define_class(const char *name, VALUE super)
return klass;
}
if (!super) {
rb_raise(rb_eArgError, "no super class for `%s'", name);
rb_raise(rb_eArgError, "no super class for '%s'", name);
}
klass = rb_define_class_id(id, super);
rb_vm_add_root_module(klass);
Expand Down Expand Up @@ -1030,7 +1030,7 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super)
return klass;
}
if (!super) {
rb_raise(rb_eArgError, "no super class for `%"PRIsVALUE"::%"PRIsVALUE"'",
rb_raise(rb_eArgError, "no super class for '%"PRIsVALUE"::%"PRIsVALUE"'",
rb_class_path(outer), rb_id2str(id));
}
klass = rb_define_class_id(id, super);
Expand Down Expand Up @@ -1706,7 +1706,7 @@ VALUE
rb_class_attached_object(VALUE klass)
{
if (!FL_TEST(klass, FL_SINGLETON)) {
rb_raise(rb_eTypeError, "`%"PRIsVALUE"' is not a singleton class", klass);
rb_raise(rb_eTypeError, "'%"PRIsVALUE"' is not a singleton class", klass);
}

return RCLASS_ATTACHED_OBJECT(klass);
Expand Down
2 changes: 1 addition & 1 deletion compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,7 @@ access_outer_variables(const rb_iseq_t *iseq, int level, ID id, bool write)
COMPILE_ERROR(iseq, ISEQ_LAST_LINE(iseq), "can not yield from isolated Proc");
}
else {
COMPILE_ERROR(iseq, ISEQ_LAST_LINE(iseq), "can not access variable `%s' from isolated Proc", rb_id2name(id));
COMPILE_ERROR(iseq, ISEQ_LAST_LINE(iseq), "can not access variable '%s' from isolated Proc", rb_id2name(id));
}
}

Expand Down
2 changes: 1 addition & 1 deletion debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ ruby_env_debug_option(const char *str, int len, void *arg)
--len; \
} \
if (len > 0) { \
fprintf(stderr, "ignored "name" option: `%.*s'\n", len, str); \
fprintf(stderr, "ignored "name" option: '%.*s'\n", len, str); \
} \
} while (0)
#define SET_WHEN_UINT(name, vals, num, req) \
Expand Down
6 changes: 3 additions & 3 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,15 @@ setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE
e = rb_obj_as_string(mesg);
ec->errinfo = mesg;
if (file && line) {
e = rb_sprintf("Exception `%"PRIsVALUE"' at %s:%d - %"PRIsVALUE"\n",
e = rb_sprintf("Exception '%"PRIsVALUE"' at %s:%d - %"PRIsVALUE"\n",
rb_obj_class(mesg), file, line, e);
}
else if (file) {
e = rb_sprintf("Exception `%"PRIsVALUE"' at %s - %"PRIsVALUE"\n",
e = rb_sprintf("Exception '%"PRIsVALUE"' at %s - %"PRIsVALUE"\n",
rb_obj_class(mesg), file, e);
}
else {
e = rb_sprintf("Exception `%"PRIsVALUE"' - %"PRIsVALUE"\n",
e = rb_sprintf("Exception '%"PRIsVALUE"' - %"PRIsVALUE"\n",
rb_obj_class(mesg), e);
}
warn_print_str(e);
Expand Down
6 changes: 3 additions & 3 deletions eval_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ error_pos_str(void)
return rb_sprintf("%"PRIsVALUE": ", sourcefile);
}
else if ((caller_name = rb_frame_callee()) != 0) {
return rb_sprintf("%"PRIsVALUE":%d:in `%"PRIsVALUE"': ",
return rb_sprintf("%"PRIsVALUE":%d:in '%"PRIsVALUE"': ",
sourcefile, sourceline,
rb_id2str(caller_name));
}
Expand Down Expand Up @@ -392,7 +392,7 @@ rb_ec_error_print(rb_execution_context_t *volatile ec, volatile VALUE errinfo)
rb_ec_error_print_detailed(ec, errinfo, Qnil, Qundef);
}

#define undef_mesg_for(v, k) rb_fstring_lit("undefined"v" method `%1$s' for "k" `%2$s'")
#define undef_mesg_for(v, k) rb_fstring_lit("undefined"v" method '%1$s' for "k" '%2$s'")
#define undef_mesg(v) ( \
is_mod ? \
undef_mesg_for(v, "module") : \
Expand Down Expand Up @@ -420,7 +420,7 @@ rb_print_undef_str(VALUE klass, VALUE name)
rb_name_err_raise_str(undef_mesg(""), klass, name);
}

#define inaccessible_mesg_for(v, k) rb_fstring_lit("method `%1$s' for "k" `%2$s' is "v)
#define inaccessible_mesg_for(v, k) rb_fstring_lit("method '%1$s' for "k" '%2$s' is "v)
#define inaccessible_mesg(v) ( \
is_mod ? \
inaccessible_mesg_for(v, "module") : \
Expand Down
2 changes: 1 addition & 1 deletion ext/-test-/struct/member.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bug_struct_get(VALUE obj, VALUE name)
ID id = rb_check_id(&name);

if (!id) {
rb_name_error_str(name, "`%"PRIsVALUE"' is not a struct member", name);
rb_name_error_str(name, "'%"PRIsVALUE"' is not a struct member", name);
}
return rb_struct_getmember(obj, id);
}
Expand Down
6 changes: 3 additions & 3 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3666,15 +3666,15 @@ rb_default_home_dir(VALUE result)
* lookup by getuid() has a chance of succeeding.
*/
if (NIL_P(login_name)) {
rb_raise(rb_eArgError, "couldn't find login name -- expanding `~'");
rb_raise(rb_eArgError, "couldn't find login name -- expanding '~'");
}
# endif /* !defined(HAVE_GETPWUID_R) && !defined(HAVE_GETPWUID) */

VALUE pw_dir = rb_getpwdirnam_for_login(login_name);
if (NIL_P(pw_dir)) {
pw_dir = rb_getpwdiruid();
if (NIL_P(pw_dir)) {
rb_raise(rb_eArgError, "couldn't find home for uid `%ld'", (long)getuid());
rb_raise(rb_eArgError, "couldn't find home for uid '%ld'", (long)getuid());
}
}

Expand All @@ -3685,7 +3685,7 @@ rb_default_home_dir(VALUE result)
}
#endif /* defined HAVE_PWD_H */
if (!dir) {
rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `~'");
rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding '~'");
}
return copy_home_path(result, dir);
}
Expand Down
2 changes: 1 addition & 1 deletion io.c
Original file line number Diff line number Diff line change
Expand Up @@ -8612,7 +8612,7 @@ deprecated_str_setter(VALUE val, ID id, VALUE *var)
{
rb_str_setter(val, id, &val);
if (!NIL_P(val)) {
rb_warn_deprecated("`%s'", NULL, rb_id2name(id));
rb_warn_deprecated("'%s'", NULL, rb_id2name(id));
}
*var = val;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/delegate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ def !
# method calls are being delegated to.
#
def __getobj__
__raise__ ::NotImplementedError, "need to define `__getobj__'"
__raise__ ::NotImplementedError, "need to define '__getobj__'"
end

#
# This method must be overridden by subclasses and change the object delegate
# to _obj_.
#
def __setobj__(obj)
__raise__ ::NotImplementedError, "need to define `__setobj__'"
__raise__ ::NotImplementedError, "need to define '__setobj__'"
end

#
Expand Down
4 changes: 2 additions & 2 deletions lib/fileutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ def user_mask(target) #:nodoc:
when "a"
mask | 07777
else
raise ArgumentError, "invalid `who' symbol in file mode: #{chr}"
raise ArgumentError, "invalid 'who' symbol in file mode: #{chr}"
end
end
end
Expand Down Expand Up @@ -1705,7 +1705,7 @@ def symbolic_modes_to_i(mode_sym, path) #:nodoc:
copy_mask = user_mask(chr)
(current_mode & copy_mask) / (copy_mask & 0111) * (user_mask & 0111)
else
raise ArgumentError, "invalid `perm' symbol in file mode: #{chr}"
raise ArgumentError, "invalid 'perm' symbol in file mode: #{chr}"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/irb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ def handle_exception(exc)
lines.map{ |l| l + "\n" }.join
}
# The "<top (required)>" in "(irb)" may be the top level of IRB so imitate the main object.
message = message.gsub(/\(irb\):(?<num>\d+):in `<(?<frame>top \(required\))>'/) { "(irb):#{$~[:num]}:in `<main>'" }
message = message.gsub(/\(irb\):(?<num>\d+):in (?<open_quote>[`'])<(?<frame>top \(required\))>'/) { "(irb):#{$~[:num]}:in #{$~[:open_quote]}<main>'" }
puts message
puts 'Maybe IRB bug!' if irb_bug
rescue Exception => handler_exc
Expand Down
2 changes: 1 addition & 1 deletion lib/optparse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ def pretty_print(q) # :nodoc:
def accept(t, pat = /.*/m, &block)
if pat
pat.respond_to?(:match) or
raise TypeError, "has no `match'", ParseError.filter_backtrace(caller(2))
raise TypeError, "has no 'match'", ParseError.filter_backtrace(caller(2))
else
pat = t if t.respond_to?(:match)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ostruct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def delete_field(name, &block)
end
@table.delete(sym) do
return yield if block
raise! NameError.new("no field `#{sym}' in #{self}", sym)
raise! NameError.new("no field '#{sym}' in #{self}", sym)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/pstore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def fetch(key, default=PStore::Error)
in_transaction
unless @table.key? key
if default == PStore::Error
raise PStore::Error, format("undefined key `%s'", key)
raise PStore::Error, format("undefined key '%s'", key)
else
return default
end
Expand Down
2 changes: 1 addition & 1 deletion lib/reline/history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def <<(val)
private def check_index(index)
index += size if index < 0
if index < -2147483648 or 2147483647 < index
raise RangeError.new("integer #{index} too big to convert to `int'")
raise RangeError.new("integer #{index} too big to convert to 'int'")
end
# If history_size is negative, history size is unlimited.
if @config.history_size.positive?
Expand Down
2 changes: 1 addition & 1 deletion lib/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def parse(date, now=self.now)
#
def strptime(date, format, now=self.now)
d = Date._strptime(date, format)
raise ArgumentError, "invalid date or strptime format - `#{date}' `#{format}'" unless d
raise ArgumentError, "invalid date or strptime format - '#{date}' '#{format}'" unless d
if seconds = d[:seconds]
if sec_fraction = d[:sec_fraction]
usec = sec_fraction * 1000000
Expand Down
2 changes: 1 addition & 1 deletion lib/tmpdir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def create(basename, tmpdir=nil, max_try: nil, **opts)
n ||= 0
n += 1
retry if !max_try or n < max_try
raise "cannot generate temporary name using `#{basename}' under `#{tmpdir}'"
raise "cannot generate temporary name using '#{basename}' under '#{tmpdir}'"
end
path
end
Expand Down
12 changes: 6 additions & 6 deletions marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,11 @@ w_obj_each(ID id, VALUE value, st_data_t a)

if (to_be_skipped_id(id)) {
if (id == s_encoding_short) {
rb_warn("instance variable `"name_s_encoding_short"' on class %"PRIsVALUE" is not dumped",
rb_warn("instance variable '"name_s_encoding_short"' on class %"PRIsVALUE" is not dumped",
CLASS_OF(arg->obj));
}
if (id == s_ruby2_keywords_flag) {
rb_warn("instance variable `"name_s_ruby2_keywords_flag"' on class %"PRIsVALUE" is not dumped",
rb_warn("instance variable '"name_s_ruby2_keywords_flag"' on class %"PRIsVALUE" is not dumped",
CLASS_OF(arg->obj));
}
return ST_CONTINUE;
Expand Down Expand Up @@ -1796,7 +1796,7 @@ append_extmod(VALUE obj, VALUE extmod)
#define prohibit_ivar(type, str) do { \
if (!ivp || !*ivp) break; \
rb_raise(rb_eTypeError, \
"can't override instance variable of "type" `%"PRIsVALUE"'", \
"can't override instance variable of "type" '%"PRIsVALUE"'", \
(str)); \
} while (0)

Expand Down Expand Up @@ -2133,7 +2133,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
st_data_t d;

if (!rb_obj_respond_to(klass, s_load, TRUE)) {
rb_raise(rb_eTypeError, "class %"PRIsVALUE" needs to have method `_load'",
rb_raise(rb_eTypeError, "class %"PRIsVALUE" needs to have method '_load'",
name);
}
data = r_string(arg);
Expand Down Expand Up @@ -2169,7 +2169,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
append_extmod(v, extmod);
}
if (!rb_obj_respond_to(v, s_mload, TRUE)) {
rb_raise(rb_eTypeError, "instance of %"PRIsVALUE" needs to have method `marshal_load'",
rb_raise(rb_eTypeError, "instance of %"PRIsVALUE" needs to have method 'marshal_load'",
name);
}
v = r_entry(v, arg);
Expand Down Expand Up @@ -2215,7 +2215,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
v = r_entry(v, arg);
if (!rb_obj_respond_to(v, s_load_data, TRUE)) {
rb_raise(rb_eTypeError,
"class %"PRIsVALUE" needs to have instance method `_load_data'",
"class %"PRIsVALUE" needs to have instance method '_load_data'",
name);
}
r = r_object0(arg, partial, 0, extmod);
Expand Down