Menu

#994 PreviousDeleted exception has totally wrong message

open
ruby (61)
5
2022-02-02
2009-02-11
No

SWIG_Ruby_ConvertPtrAndOwn may return a SWIG_ObjectPreviouslyDeletedError.

In a method wrapper, such error results are catched like this:

res1 = SWIG_ConvertPtr(self,
&argp1,SWIGTYPE_p_Foo, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1),
Ruby_Format_TypeError( "", "Foo *","DoSomething", 1,
self ));
}

This way the ObjectPreviouslyDeletedError gets a TypeError message which is totally wrong and misleading.

Previous versions of SWIG have thrown an exception with a message like "This Animal * already released" (see ruby documentation.

I think the last working version was 1.3.27. See:

http://swig.svn.sourceforge.net/viewvc/swig/tags/rel-1-3-27/SWIG/Lib/ruby/rubydef.swg?revision=7668&view=markup

Tobias

Discussion

  • William Fulton

    William Fulton - 2012-12-10
    • assigned_to: gga73 --> kkaempf
     
  • Olly Betts

    Olly Betts - 2022-02-02

    There's no testcase here, but looking at the code and its history I think this is still the case, but also it doesn't look to me like this ever actually worked.

    To fix, Ruby_Format_TypeError could take res1 as a parameter (and probably get renamed).

    It'd be really useful to have a way to reproduce the situation where this happens though. It's not clear to me how to trigger it.

     

Log in to post a comment.