From a0b9f48674f104d79b374b104635ab4d88d32ec8 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 2 Aug 2011 22:46:34 +0000 Subject: [PATCH] * encoding.c (enc_find): mistakenly remained !. [Bug #5150] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ encoding.c | 2 +- test/ruby/test_encoding.rb | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b9f73f9232..7a2ed0738b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Aug 3 07:46:30 2011 Nobuyoshi Nakada + + * encoding.c (enc_find): mistakenly remained !. [Bug #5150] + Wed Aug 3 00:11:08 2011 Tanaka Akira * lib/prettyprint.rb: update document. [ruby-core:36776] diff --git a/encoding.c b/encoding.c index 8e80e8ce66..e5bc75b4ef 100644 --- a/encoding.c +++ b/encoding.c @@ -1054,7 +1054,7 @@ static VALUE enc_find(VALUE klass, VALUE enc) { int idx; - if (!SPECIAL_CONST_P(enc) && BUILTIN_TYPE(enc) == T_DATA && is_data_encoding(enc)) + if (RB_TYPE_P(enc, T_DATA) && is_data_encoding(enc)) return enc; idx = str_to_encindex(enc); if (idx == UNSPECIFIED_ENCODING) return Qnil; diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb index 6ddac1d51a..c1c50a5dfa 100644 --- a/test/ruby/test_encoding.rb +++ b/test/ruby/test_encoding.rb @@ -50,6 +50,9 @@ class TestEncoding < Test::Unit::TestCase exit Encoding.find("filesystem") == Encoding::EUC_JP EOS end + + bug5150 = '[ruby-dev:44327]' + assert_raise(TypeError, bug5150) {Encoding.find(1)} end def test_replicate