|
From: William S F. <ws...@fu...> - 2017-09-19 18:33:33
|
On 19 September 2017 at 14:44, Dave Vitek <dv...@gr...> wrote:
> On 9/19/2017 2:48 AM, William S Fulton wrote:
>
>
>
> On 18 September 2017 at 19:37, Dave Vitek <dv...@gr...> wrote:
>
>> On 9/18/2017 2:03 PM, William S Fulton wrote:
>>
>>
>>
>> On 7 August 2017 at 22:34, Dave Vitek <dv...@gr...> wrote:
>>
>>> Hi all,
>>>
>>> If I use %exceptionclass with python, then staticmethods don't get
>>> attached to the class. I've tracked down the cause of the problem.
>>>
>>> In python.cxx, we have:
>>>
>>> if (GetFlag(n, "feature:exceptionclass")) {
>>> classic = 1;
>>> modern = 0;
>>> }
>>>
>>> Introduced many years ago by:
>>> https://github.com/swig/swig/commit/bab11e11f4a9bbd016a15dd5
>>> abf56dd12f1368c2
>>>
>>> It prevents this code from executing:
>>>
>>> if (!classic) {
>>> if (!modern)
>>> Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
>>> Printv(f_shadow, tab4, symname, " = staticmethod(", module,
>>> ".", Swig_name_member(NSPACE_TODO, class_name, symname),
>>> ")\n", NIL);
>>> }
>>>
>>> This means that Exception classes will not have static methods in
>>> python. Does anyone know the intent of the "classic = 1" assignment? Is
>>> there a good reason why classes inheriting from Exception cannot have
>>> static methods?
>>>
>>
>> I can't think why this change was put for %exceptionclass. Perhaps
>> something to do with exception classes shouldn't be derived from object,
>> but instead should be derived from Exception?? classic mode removes classes
>> being derived from object. Perhaps you can try see if it works as you'd
>> like it and send a patch in to fix.
>>
>> William
>>
>> Here's the patch we've been using successfully since the day I sent the
>> OP. The globals are a little nasty, but this was the best way to avoid
>> changing behavior in other respects.
>>
>> Thanks. Thinking about it further, as we are going to drop the -classic
> and -modern options in swig-4.0.0, this should just get resolved without
> the need to add in the additional complexity this patch introduces.
>
> William
>
> One thing I noticed about "-O" that scared me away was that when a
> function is passed the wrong types of arguments, it no longer emits the
> full list of overloads. Instead, the exception only describes one of
> possibly many overloads. It would be nice if it were still possible to get
> the full list of overloads in the next version.
>
> Mmm, this ought to be added to the issues list on Github as otherwise
it'll get forgotten about. It'll need someone to contribute a patch for
anyone keen on seeing this though.
William
|