You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Andreas Stieger <An...@gmx.de> on 2015/02/11 13:58:09 UTC

[PATCH] Fix swig-py bindings with SWIG 3.0.4

Hello,

> I saw build errors in the bindings with SWIG 3.0.4:
> ./subversion/bindings/swig/core.i:792: Error: Unknown SWIG preprocessor
> directive: The (if this is a block of target language code, delimit it
> with %{ and %})

And here is the missing part for proxy.swg for review...

[[[
Follow-up to 1655262,1658347: Fix for python bindings build with Swig 3.0.x

* subversion/bindings/swig/include/proxy.swg:
  Escape comments

Patch by: Dominique Leuenberger <di...@opensuse.org>
Found by: me
]]]

Andreas

Re: [PATCH] Fix swig-py bindings with SWIG 3.0.4

Posted by Branko Čibej <br...@wandisco.com>.
On 10.04.2015 17:44, Andreas Stieger wrote:
> Am 10.04.2015 10:25 schrieb Joe Orton <jo...@redhat.com>:
>> On Wed, Feb 11, 2015 at 02:36:31PM +0100, Branko Čibej wrote: 
>>> This is clearly a bug in Swig; I can't imagine it being anything else. 
>>> The only workaround I could find was to remove the comments entirely. 
>> Same here.  Filed as https://github.com/swig/swig/issues/379 
>>
>>> Even then, the generated Python bindings don't work because of the use 
>>> of the argument-less svn_pool_create() in the wrong context, but I think 
>>> this is a different bug. 
>> This is https://github.com/swig/swig/issues/377 but there are a number 
>> of similar issues with default argument handling in recent SWIG 3.0.x so 
>> that might be a dupe.  Has anybody found a workaround for this? 
> Unfortunately not. I tried some swig master patches that looked relevant but in the end decided to wait for a fixed upstream release, while disabling the swig-py tests meanwhile.

I went back to using the latest Swig 2.x for bindings tests.

-- Brane

Re: [PATCH] Fix swig-py bindings with SWIG 3.0.4

Posted by Andreas Stieger <an...@gmx.de>.
Am 10.04.2015 10:25 schrieb Joe Orton <jo...@redhat.com>:
>
> On Wed, Feb 11, 2015 at 02:36:31PM +0100, Branko Čibej wrote: 
> > This is clearly a bug in Swig; I can't imagine it being anything else. 
> > The only workaround I could find was to remove the comments entirely. 
>
> Same here.  Filed as https://github.com/swig/swig/issues/379 
>
> > Even then, the generated Python bindings don't work because of the use 
> > of the argument-less svn_pool_create() in the wrong context, but I think 
> > this is a different bug. 
>
> This is https://github.com/swig/swig/issues/377 but there are a number 
> of similar issues with default argument handling in recent SWIG 3.0.x so 
> that might be a dupe.  Has anybody found a workaround for this? 

Unfortunately not. I tried some swig master patches that looked relevant but in the end decided to wait for a fixed upstream release, while disabling the swig-py tests meanwhile.

Andreas

Re: [PATCH] Fix swig-py bindings with SWIG 3.0.4

Posted by Joe Orton <jo...@redhat.com>.
On Wed, Feb 11, 2015 at 02:36:31PM +0100, Branko Čibej wrote:
> This is clearly a bug in Swig; I can't imagine it being anything else.
> The only workaround I could find was to remove the comments entirely.

Same here.  Filed as https://github.com/swig/swig/issues/379

> Even then, the generated Python bindings don't work because of the use
> of the argument-less svn_pool_create() in the wrong context, but I think
> this is a different bug.

This is https://github.com/swig/swig/issues/377 but there are a number 
of similar issues with default argument handling in recent SWIG 3.0.x so 
that might be a dupe.  Has anybody found a workaround for this?

Regards, Joe

Re: [PATCH] Fix swig-py bindings with SWIG 3.0.4

Posted by Branko Čibej <br...@wandisco.com>.
On 11.02.2015 13:58, Andreas Stieger wrote:
> Hello,
>
>> I saw build errors in the bindings with SWIG 3.0.4:
>> ./subversion/bindings/swig/core.i:792: Error: Unknown SWIG preprocessor
>> directive: The (if this is a block of target language code, delimit it
>> with %{ and %})
> And here is the missing part for proxy.swg for review...
>
> [[[
> Follow-up to 1655262,1658347: Fix for python bindings build with Swig 3.0.x
>
> * subversion/bindings/swig/include/proxy.swg:
>   Escape comments
>
> Patch by: Dominique Leuenberger <di...@opensuse.org>
> Found by: me
> ]]]
>
> Andreas

Unfortunately, this does not fix the Python bindings. Yes, with this
patch, 'make swig-py' works, but 'make check-swig-py' fails, because the
comments are not expanded correctly in the generated Python file.

This is from the generated subversion/bindings/swig/python/libsvn/core.py:

    def __getattr__(self, name):
      """Get an attribute from this object"""
      self.assert_valid()

      value = _swig_getattr(self, self.__class__, name)

    #If we got back a different object than we have, we need to copy all our
    etadata into it, so that it looks identical%}
      members = self.__dict__.get("_members")
      if members is not None:
        _copy_metadata_deep(value, members.get(name))


And so on. Note how the multi-line comments are mangled, and how the
closing '%}' is still there. According to the docs, the whole
%pythoncode block should be enclosed in '%{' '%}' rather than the
current '{' '}'; doing that lets 'make swig-py' work, but the comments
are still mangled.

This is clearly a bug in Swig; I can't imagine it being anything else.
The only workaround I could find was to remove the comments entirely.
Even then, the generated Python bindings don't work because of the use
of the argument-less svn_pool_create() in the wrong context, but I think
this is a different bug.

For now, I can only recommend that we do not support Swig 3.0.

-- Brane