Unconditionally warn "unknown pack/unpack directive"

[Bug #19150]
This commit is contained in:
Yusuke Endoh 2022-12-16 04:04:41 +09:00 коммит произвёл Benoit Daloze
Родитель b9ea83fc1c
Коммит ee7a338d2b
2 изменённых файлов: 4 добавлений и 12 удалений

4
pack.c
Просмотреть файл

@ -167,8 +167,8 @@ unknown_directive(const char *mode, char type, VALUE fmt)
snprintf(unknown, sizeof(unknown), "\\x%.2x", type & 0xff);
}
fmt = rb_str_quote_unprintable(fmt);
rb_warning("unknown %s directive '%s' in '%"PRIsVALUE"'",
mode, unknown, fmt);
rb_warn("unknown %s directive '%s' in '%"PRIsVALUE"'",
mode, unknown, fmt);
}
static float

Просмотреть файл

@ -777,21 +777,13 @@ EXPECTED
end
def test_pack_garbage
assert_warn("") do
assert_equal "\000", [0].pack("*U")
end
assert_warning(%r%unknown pack directive '\*' in '\*U'$%) do
assert_warn(%r%unknown pack directive '\*' in '\*U'$%) do
assert_equal "\000", [0].pack("*U")
end
end
def test_unpack_garbage
assert_warn("") do
assert_equal [0], "\000".unpack("*U")
end
assert_warning(%r%unknown unpack directive '\*' in '\*U'$%) do
assert_warn(%r%unknown unpack directive '\*' in '\*U'$%) do
assert_equal [0], "\000".unpack("*U")
end
end