mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
process.c: preserve encodings
* process.c (rlimit_resource_type, rlimit_resource_value): preserve argument encoding in error messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
956745eee2
commit
c0dee604fe
2 changed files with 6 additions and 2 deletions
|
@ -4527,7 +4527,7 @@ rlimit_resource_type(VALUE rtype)
|
|||
if (r != -1)
|
||||
return r;
|
||||
|
||||
rb_raise(rb_eArgError, "invalid resource name: %s", name);
|
||||
rb_raise(rb_eArgError, "invalid resource name: %"PRIsVALUE, rtype);
|
||||
|
||||
UNREACHABLE;
|
||||
}
|
||||
|
@ -4567,7 +4567,7 @@ rlimit_resource_value(VALUE rval)
|
|||
#ifdef RLIM_SAVED_CUR
|
||||
if (strcmp(name, "SAVED_CUR") == 0) return RLIM_SAVED_CUR;
|
||||
#endif
|
||||
rb_raise(rb_eArgError, "invalid resource value: %s", name);
|
||||
rb_raise(rb_eArgError, "invalid resource value: %"PRIsVALUE, rval);
|
||||
|
||||
UNREACHABLE;
|
||||
}
|
||||
|
|
|
@ -116,11 +116,15 @@ class TestProcess < Test::Unit::TestCase
|
|||
}
|
||||
assert_raise(ArgumentError) { Process.getrlimit(:FOO) }
|
||||
assert_raise(ArgumentError) { Process.getrlimit("FOO") }
|
||||
assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Process.getrlimit("\u{30eb 30d3 30fc}") }
|
||||
end
|
||||
|
||||
def test_rlimit_value
|
||||
return unless rlimit_exist?
|
||||
assert_raise(ArgumentError) { Process.setrlimit(:FOO, 0) }
|
||||
assert_raise(ArgumentError) { Process.setrlimit(:CORE, :FOO) }
|
||||
assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Process.setrlimit("\u{30eb 30d3 30fc}", 0) }
|
||||
assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Process.setrlimit(:CORE, "\u{30eb 30d3 30fc}") }
|
||||
with_tmpchdir do
|
||||
s = run_in_child(<<-'End')
|
||||
cur, max = Process.getrlimit(:NOFILE)
|
||||
|
|
Loading…
Reference in a new issue