summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--encoding.c14
-rw-r--r--test/ruby/test_m17n.rb2
3 files changed, 15 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 4fc8d28baa..56d8b5b6bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Aug 30 07:48:48 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * encoding.c (enc_compatible_p): add SPECIAL_CONST_P check.
+
+ * test/ruby/test_m17n.rb (test_compatible): fix test.
+
Sat Aug 30 02:48:11 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (rb_obj_freeze): update rdoc to mention RuntimeError
diff --git a/encoding.c b/encoding.c
index 21614245ae..bb6f5b269e 100644
--- a/encoding.c
+++ b/encoding.c
@@ -880,13 +880,15 @@ enc_compatible_p(VALUE klass, VALUE str1, VALUE str2)
{
rb_encoding *enc;
- if (BUILTIN_TYPE(str1) != T_STRING && BUILTIN_TYPE(str1) != T_REGEXP) {
- rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)",
- rb_obj_classname(str1));
+ if (SPECIAL_CONST_P(str1) ||
+ BUILTIN_TYPE(str1) != T_STRING && BUILTIN_TYPE(str1) != T_REGEXP) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)",
+ rb_obj_classname(str1));
}
- if (BUILTIN_TYPE(str2) != T_STRING && BUILTIN_TYPE(str2) != T_REGEXP) {
- rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)",
- rb_obj_classname(str2));
+ if (SPECIAL_CONST_P(str2) ||
+ BUILTIN_TYPE(str2) != T_STRING && BUILTIN_TYPE(str2) != T_REGEXP) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)",
+ rb_obj_classname(str2));
}
if (!enc_capable(str1)) return Qnil;
if (!enc_capable(str2)) return Qnil;
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index e82e04beb7..a878227534 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -1280,7 +1280,7 @@ class TestM17N < Test::Unit::TestCase
end
def test_compatible
- assert_equal(nil, Encoding.compatible?("",0), "moved from btest/knownbug")
+ assert_raise(TypeError) {Encoding.compatible?("",0)}
end
def test_force_encoding