aboutsummaryrefslogtreecommitdiffstats
path: root/encoding.c
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-03 13:52:13 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-03 13:52:13 +0000
commit080d700e1d79e9f370d74825cd1392cf61b404bf (patch)
tree94ad4d4fc34cefbc5ec15d10049c5129d1ac4999 /encoding.c
parenta35499268878ee7afff4cd782ce854fb609ba512 (diff)
downloadruby-080d700e1d79e9f370d74825cd1392cf61b404bf.tar.gz
encoding.c (enc_set_index): raise instead of rb_bug() for non-encoding capable objects
* Add spec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/encoding.c b/encoding.c
index 8d1894aa91..eac4d7c50a 100644
--- a/encoding.c
+++ b/encoding.c
@@ -819,7 +819,9 @@ rb_enc_get_index(VALUE obj)
static void
enc_set_index(VALUE obj, int idx)
{
- if (!enc_capable(obj)) rb_bug("enc_set_index: not capable object");
+ if (!enc_capable(obj)) {
+ rb_raise(rb_eArgError, "cannot set encoding on non-encoding capable object");
+ }
if (idx < ENCODING_INLINE_MAX) {
ENCODING_SET_INLINED(obj, idx);