summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/json/parser/parser.c2
-rw-r--r--ext/json/parser/parser.h2
-rw-r--r--ext/json/parser/parser.rl2
-rwxr-xr-xtest/json/test_json.rb4
5 files changed, 10 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 24a19d83f1..4a36a1c9da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
-Sat Feb 5 10:29:52 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Feb 5 11:29:10 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/json/parser/parser.h (GET_PARSER): raise TypeError.
+
+ * ext/json/parser/parser.rl (cParser_initialize): ditto.
* ext/json/parser/parser.h (GET_PARSER): check if initialized.
[ruby-core:35079]
diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c
index 22c8167fc7..418c1c32f0 100644
--- a/ext/json/parser/parser.c
+++ b/ext/json/parser/parser.c
@@ -1613,7 +1613,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
GET_PARSER_INIT;
if (json->Vsource) {
- rb_raise(rb_eArgError, "already initialized instance");
+ rb_raise(rb_eTypeError, "already initialized instance");
}
rb_scan_args(argc, argv, "11", &source, &opts);
source = convert_encoding(StringValue(source));
diff --git a/ext/json/parser/parser.h b/ext/json/parser/parser.h
index 5d4532b948..a344da058c 100644
--- a/ext/json/parser/parser.h
+++ b/ext/json/parser/parser.h
@@ -45,7 +45,7 @@ typedef struct JSON_ParserStruct {
#define GET_PARSER \
GET_PARSER_INIT; \
- if (!json->Vsource) rb_raise(rb_eArgError, "uninitialized instance")
+ if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
#define GET_PARSER_INIT \
JSON_Parser *json; \
Data_Get_Struct(self, JSON_Parser, json)
diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl
index 680242732e..278386432b 100644
--- a/ext/json/parser/parser.rl
+++ b/ext/json/parser/parser.rl
@@ -611,7 +611,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
GET_PARSER_INIT;
if (json->Vsource) {
- rb_raise(rb_eArgError, "already initialized instance");
+ rb_raise(rb_eTypeError, "already initialized instance");
}
rb_scan_args(argc, argv, "11", &source, &opts);
source = convert_encoding(StringValue(source));
diff --git a/test/json/test_json.rb b/test/json/test_json.rb
index cb70085242..aea50485fc 100755
--- a/test/json/test_json.rb
+++ b/test/json/test_json.rb
@@ -394,8 +394,8 @@ EOT
def test_allocate
json = JSON::Parser.new("{}")
- assert_raises(ArgumentError, '[ruby-core:35079]') {json.__send__(:initialize, "{}")}
+ assert_raises(TypeError, '[ruby-core:35079]') {json.__send__(:initialize, "{}")}
json = JSON::Parser.allocate
- assert_raises(ArgumentError, '[ruby-core:35079]') {json.source}
+ assert_raises(TypeError, '[ruby-core:35079]') {json.source}
end
end