ruby-changes:8207
From: nobu <ko1@a...>
Date: Fri, 10 Oct 2008 00:22:01 +0900 (JST)
Subject: [ruby-changes:8207] Ruby:r19735 (ruby_1_8, trunk): * lib/optparse.rb (ParseError.filter_backtrace): removes internal
nobu 2008-10-10 00:21:42 +0900 (Fri, 10 Oct 2008) New Revision: 19735 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19735 Log: * lib/optparse.rb (ParseError.filter_backtrace): removes internal backtrace. Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/lib/optparse.rb branches/ruby_1_8/version.h trunk/ChangeLog trunk/lib/optparse.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 19734) +++ ChangeLog (revision 19735) @@ -1,3 +1,8 @@ +Fri Oct 10 00:21:39 2008 Nobuyoshi Nakada <nobu@r...> + + * lib/optparse.rb (ParseError.filter_backtrace): removes internal + backtrace. + Fri Oct 10 00:11:16 2008 Yusuke Endoh <mame@t...> * transcode.c (rb_econv_add_coverter): remove unnecessary NULL check. Index: lib/optparse.rb =================================================================== --- lib/optparse.rb (revision 19734) +++ lib/optparse.rb (revision 19735) @@ -301,7 +301,8 @@ end def self.incompatible_argument_styles(arg, t) - raise ArgumentError, "#{arg}: incompatible argument styles\n #{self}, #{t}" + raise(ArgumentError, "#{arg}: incompatible argument styles\n #{self}, #{t}", + ParseError.filter_backtrace(caller(2))) end def self.pattern @@ -529,7 +530,8 @@ # def accept(t, pat = /.*/nm, &block) if pat - pat.respond_to?(:match) or raise TypeError, "has no `match'" + pat.respond_to?(:match) or + raise TypeError, "has no `match'", ParseError.filter_backtrace(caller(2)) else pat = t if t.respond_to?(:match) end @@ -987,12 +989,8 @@ # def notwice(obj, prv, msg) unless !prv or prv == obj - begin - raise ArgumentError, "argument #{msg} given twice: #{obj}" - rescue - $@[0, 2] = nil - raise - end + raise(ArgumentError, "argument #{msg} given twice: #{obj}", + ParseError.filter_backtrace(caller(2))) end obj end @@ -1097,7 +1095,7 @@ end o.each {|pat, *v| pattern[pat] = v.fetch(0) {pat}} when Module - raise ArgumentError, "unsupported argument type: #{o}" + raise ArgumentError, "unsupported argument type: #{o}", ParseError.filter_backtrace(caller(4)) when *ArgumentStyle.keys style = notwice(ArgumentStyle[o], style, 'style') when /^--no-([^\[\]=\s]*)(.+)?/ @@ -1162,7 +1160,9 @@ s = (style || default_style).new(pattern || default_pattern, conv, sdesc, ldesc, arg, desc, block) elsif !block - raise ArgumentError, "no switch given" if style or pattern + if style or pattern + raise ArgumentError, "no switch given", ParseError.filter_backtrace(caller) + end s = desc else short << pattern @@ -1605,13 +1605,17 @@ argv end - def set_backtrace(array) + def self.filter_backtrace(array) unless $DEBUG array.delete_if(&%r"\A#{Regexp.quote(__FILE__)}:"o.method(:=~)) end - super(array) + array end + def set_backtrace(array) + super(self.class.filter_backtrace(array)) + end + def set_option(opt, eq) if eq @args[0] = opt Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 19734) +++ ruby_1_8/ChangeLog (revision 19735) @@ -1,3 +1,8 @@ +Fri Oct 10 00:21:39 2008 Nobuyoshi Nakada <nobu@r...> + + * lib/optparse.rb (ParseError.filter_backtrace): removes internal + backtrace. + Thu Oct 9 23:53:23 2008 Nobuyoshi Nakada <nobu@r...> * misc/ruby-style.el (ruby-style-c-mode): buffer may not have file Index: ruby_1_8/version.h =================================================================== --- ruby_1_8/version.h (revision 19734) +++ ruby_1_8/version.h (revision 19735) @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.8.7" -#define RUBY_RELEASE_DATE "2008-10-09" +#define RUBY_RELEASE_DATE "2008-10-10" #define RUBY_VERSION_CODE 187 -#define RUBY_RELEASE_CODE 20081009 +#define RUBY_RELEASE_CODE 20081010 #define RUBY_PATCHLEVEL 5000 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 7 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 9 +#define RUBY_RELEASE_DAY 10 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; Index: ruby_1_8/lib/optparse.rb =================================================================== --- ruby_1_8/lib/optparse.rb (revision 19734) +++ ruby_1_8/lib/optparse.rb (revision 19735) @@ -301,7 +301,8 @@ end def self.incompatible_argument_styles(arg, t) - raise ArgumentError, "#{arg}: incompatible argument styles\n #{self}, #{t}" + raise(ArgumentError, "#{arg}: incompatible argument styles\n #{self}, #{t}", + ParseError.filter_backtrace(caller(2))) end def self.pattern @@ -529,7 +530,8 @@ # def accept(t, pat = /.*/nm, &block) if pat - pat.respond_to?(:match) or raise TypeError, "has no `match'" + pat.respond_to?(:match) or + raise TypeError, "has no `match'", ParseError.filter_backtrace(caller(2)) else pat = t if t.respond_to?(:match) end @@ -987,12 +989,8 @@ # def notwice(obj, prv, msg) unless !prv or prv == obj - begin - raise ArgumentError, "argument #{msg} given twice: #{obj}" - rescue - $@[0, 2] = nil - raise - end + raise(ArgumentError, "argument #{msg} given twice: #{obj}", + ParseError.filter_backtrace(caller(2))) end obj end @@ -1098,7 +1096,7 @@ end o.each {|(o, *v)| pattern[o] = v.fetch(0) {o}} when Module - raise ArgumentError, "unsupported argument type: #{o}" + raise ArgumentError, "unsupported argument type: #{o}", ParseError.filter_backtrace(caller(4)) when *ArgumentStyle.keys style = notwice(ArgumentStyle[o], style, 'style') when /^--no-([^\[\]=\s]*)(.+)?/ @@ -1163,7 +1161,9 @@ s = (style || default_style).new(pattern || default_pattern, conv, sdesc, ldesc, arg, desc, block) elsif !block - raise ArgumentError, "no switch given" if style or pattern + if style or pattern + raise ArgumentError, "no switch given", ParseError.filter_backtrace(caller) + end s = desc else short << pattern @@ -1607,13 +1607,17 @@ argv end - def set_backtrace(array) + def self.filter_backtrace(array) unless $DEBUG array.delete_if(&%r"\A#{Regexp.quote(__FILE__)}:"o.method(:=~)) end - super(array) + array end + def set_backtrace(array) + super(self.class.filter_backtrace(array)) + end + def set_option(opt, eq) if eq @args[0] = opt -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/