djberg96
5/14/2005 2:21:00 PM
nobu.nok...@softhome.net wrote:
> Hi,
>
> At Sat, 14 May 2005 10:30:29 +0900,
> Daniel Berger wrote in [ruby-talk:142610]:
> > > SystemCallError does not use Exception's initialize:
> > >
> > > rb_eSystemCallError = rb_define_class("SystemCallError",
> > > rb_eStandardError);
> > > rb_define_method(rb_eSystemCallError, "initialize",
> > > syserr_initialize, -1);
>
> Accurately, syserr_initialize() directly calls exc_initialize()
> which implements Execption#initialize.
>
> > Yuck. Could it be altered to call super? Or would that cause some
> > hideous side effect?
>
> Just for efficiency, I guess.
>
>
> Index: error.c
> ===================================================================
> RCS file: /cvs/ruby/src/ruby/error.c,v
> retrieving revision 1.107
> diff -U2 -p -r1.107 error.c
> --- error.c 18 Mar 2005 03:17:27 -0000 1.107
> +++ error.c 14 May 2005 02:32:25 -0000
> @@ -387,5 +387,5 @@ exc_exception(argc, argv, self)
> if (argc == 1 && self == argv[0]) return self;
> exc = rb_obj_clone(self);
> - exc_initialize(argc, argv, exc);
> + rb_obj_call_init(exc, argc, argv);
>
> return exc;
> @@ -581,5 +581,5 @@ exit_initialize(argc, argv, exc)
> --argc;
> }
> - exc_initialize(argc, argv, exc);
> + rb_call_super(argc, argv);
> rb_iv_set(exc, "status", status);
> return exc;
> @@ -661,5 +661,5 @@ name_err_initialize(argc, argv, self)
>
> name = (argc > 1) ? argv[--argc] : Qnil;
> - exc_initialize(argc, argv, self);
> + rb_call_super(argc, argv);
> rb_iv_set(self, "name", name);
> return self;
> @@ -966,5 +966,5 @@ syserr_initialize(argc, argv, self)
> mesg = rb_str_new2(err);
> }
> - exc_initialize(1, &mesg, self);
> + rb_call_super(1, &mesg);
> rb_iv_set(self, "errno", error);
> return self;
>
>
> --
> Nobu Nakada
Will this patch be applied to the 1.8 branch? I'd like to see it in
1.8.3 but I understand if you'd rather merge it into 1.9 instead.
Regards,
Dan