Project

General

Profile

Bug #11677 » 0001-Not-raise-KeyError-when-an-arg-hash-of-sprintf-has-k.patch

yui-knk (Kaneko Yuichiro), 11/11/2015 09:28 AM

View differences:

sprintf.c
len - 2 /* without parenthesis */,
enc);
nextvalue = rb_hash_aref(hash, sym);
if (NIL_P(nextvalue) && !FL_TEST(hash, HASH_PROC_DEFAULT)) {
if (NIL_P(nextvalue) && (rb_hash_has_key(hash, sym) == Qfalse) && !FL_TEST(hash, HASH_PROC_DEFAULT)) {
rb_enc_raise(enc, rb_eKeyError, "key%.*s not found", len, start);
}
if (term == '}') goto format_s;
test/ruby/test_sprintf.rb
assert_equal("hello world", "hello %{location}" % h)
assert_equal("hello world", "hello %<location>s" % h)
end
def test_named_with_nil
h = { key: nil, key2: "key2_val" }
assert_equal("key is , key2 is key2_val", "key is %{key}, key2 is %{key2}" % h)
end
end
    (1-1/1)