1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Check if encoding capable object before check if ASCII compatible

This commit is contained in:
Nobuyoshi Nakada 2022-08-19 23:39:52 +09:00
parent d2483393cb
commit 43e8d9a050
Notes: git 2022-08-20 10:07:01 +09:00

View file

@ -2526,6 +2526,9 @@ void
rb_must_asciicompat(VALUE str)
{
rb_encoding *enc = rb_enc_get(str);
if (!enc) {
rb_raise(rb_eTypeError, "not encoding capable object");
}
if (!rb_enc_asciicompat(enc)) {
rb_raise(rb_eEncCompatError, "ASCII incompatible encoding: %s", rb_enc_name(enc));
}