[前][次][番号順一覧][スレッド一覧]

ruby-changes:25240

From: tenderlove <ko1@a...>
Date: Tue, 23 Oct 2012 06:25:20 +0900 (JST)
Subject: [ruby-changes:25240] tenderlove:r37292 (trunk): * ext/psych/parser.c: just get the constant defined in Ruby.

tenderlove	2012-10-23 06:25:02 +0900 (Tue, 23 Oct 2012)

  New Revision: 37292

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37292

  Log:
    * ext/psych/parser.c: just get the constant defined in Ruby.
    
    * ext/psych/lib/psych/syntax_error.rb: Psych::SyntaxError now inherits
      from StandardError rather than SyntaxError.  Thanks Eric Hodel!
    
    * test/psych/test_exception.rb: tests for change.

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/syntax_error.rb
    trunk/ext/psych/parser.c
    trunk/test/psych/test_exception.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37291)
+++ ChangeLog	(revision 37292)
@@ -1,3 +1,12 @@
+Tue Oct 23 06:21:05 2012  Aaron Patterson <aaron@t...>
+
+	* ext/psych/parser.c: just get the constant defined in Ruby.
+
+	* ext/psych/lib/psych/syntax_error.rb: Psych::SyntaxError now inherits
+	  from StandardError rather than SyntaxError.  Thanks Eric Hodel!
+
+	* test/psych/test_exception.rb: tests for change.
+
 Tue Oct 23 06:17:36 2012  Aaron Patterson <aaron@t...>
 
 	* ext/psych/lib/psych/scalar_scanner.rb: Cache symbols while
Index: ext/psych/lib/psych/syntax_error.rb
===================================================================
--- ext/psych/lib/psych/syntax_error.rb	(revision 37291)
+++ ext/psych/lib/psych/syntax_error.rb	(revision 37292)
@@ -1,5 +1,8 @@
 module Psych
-  class SyntaxError < ::SyntaxError
+  class Error < RuntimeError
+  end
+
+  class SyntaxError < Error
     attr_reader :file, :line, :column, :offset, :problem, :context
 
     def initialize file, line, col, offset, problem, context
Index: ext/psych/parser.c
===================================================================
--- ext/psych/parser.c	(revision 37291)
+++ ext/psych/parser.c	(revision 37292)
@@ -557,7 +557,7 @@
     rb_define_const(cPsychParser, "UTF16BE", INT2NUM(YAML_UTF16BE_ENCODING));
 
     rb_require("psych/syntax_error");
-    ePsychSyntaxError = rb_define_class_under(mPsych, "SyntaxError", rb_eSyntaxError);
+    ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError"));
 
     rb_define_method(cPsychParser, "parse", parse, -1);
     rb_define_method(cPsychParser, "mark", mark, 0);
Index: test/psych/test_exception.rb
===================================================================
--- test/psych/test_exception.rb	(revision 37291)
+++ test/psych/test_exception.rb	(revision 37292)
@@ -126,5 +126,26 @@
       assert_equal 1, w.foo
       assert_nil w.bar
     end
+
+    def test_psych_syntax_error
+      Tempfile.open(['parsefile', 'yml']) do |t|
+        t.binmode
+        t.write '--- `'
+        t.close
+
+        begin
+          Psych.parse_file t.path
+        rescue StandardError
+          assert true # count assertion
+        ensure
+          return unless $!
+
+          ancestors = $!.class.ancestors.inspect
+
+          flunk "Psych::SyntaxError not rescued by StandardError: #{ancestors}"
+        end
+      end
+    end
+
   end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]