Discussion:
[Swig-devel] 3.0.4 regression
Douglas Roark
2015-01-28 05:55:18 UTC
Permalink
Hello. I think I've found a regression bug in the latest version of
SWIG. I'm running it on some code on OS X. I get the following error
when I try to run my program.

---
File "CppBlockUtils.py", line 4075, in <lambda>
__setattr__ = lambda self, name, value: _swig_setattr(self,
BDM_CallBack, name, value)
File "CppBlockUtils.py", line 51, in _swig_setattr
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
File "CppBlockUtils.py", line 45, in _swig_setattr_nondynamic
object.__setattr__(self, name, value)
---

It looks like there's some sort of regression bug in 3.0.4, or
possibly 3.0.3. (I'm using brew to run pre-compiled SWIG binaries.
3.0.3 isn't available.) The _swig_setattr_nondynamic() call is
different. Here's what I'm seeing.

---3.0.2---
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)

---3.0.4---
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
object.__setattr__(self, name, value)
else:
raise AttributeError("You cannot add attributes to %s" % self)

Any thoughts on why the code went from "self.__dict[name] = value" to
"object.__setattr__(self, name, value)"? Is this a genuine bug? Am I
missing something?

Thanks.

Doug
William S Fulton
2015-01-28 06:07:48 UTC
Permalink
Post by Douglas Roark
Hello. I think I've found a regression bug in the latest version of
SWIG. I'm running it on some code on OS X. I get the following error
when I try to run my program.
---
File "CppBlockUtils.py", line 4075, in <lambda>
__setattr__ = lambda self, name, value: _swig_setattr(self,
BDM_CallBack, name, value)
File "CppBlockUtils.py", line 51, in _swig_setattr
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
File "CppBlockUtils.py", line 45, in _swig_setattr_nondynamic
object.__setattr__(self, name, value)
---
It looks like there's some sort of regression bug in 3.0.4, or
possibly 3.0.3. (I'm using brew to run pre-compiled SWIG binaries.
3.0.3 isn't available.) The _swig_setattr_nondynamic() call is
different. Here's what I'm seeing.
---3.0.2---
if (name == "thisown"): return self.this.own(value)
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
self.__dict__[name] = value
raise AttributeError("You cannot add attributes to %s" % self)
---3.0.4---
return self.this.own(value)
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
return method(self, value)
object.__setattr__(self, name, value)
raise AttributeError("You cannot add attributes to %s" % self)
Any thoughts on why the code went from "self.__dict[name] = value" to
"object.__setattr__(self, name, value)"? Is this a genuine bug? Am I
missing something?
What command line options do you use?

William
Douglas Roark
2015-01-28 06:12:46 UTC
Permalink
On Wed, Jan 28, 2015 at 1:07 AM, William S Fulton
Post by William S Fulton
What command line options do you use?
swig -c++ -python -classic -threads -outdir ../ -v CppBlockUtils.i

Doug
William S Fulton
2015-01-28 12:44:47 UTC
Permalink
Post by Douglas Roark
On Wed, Jan 28, 2015 at 1:07 AM, William S Fulton
Post by William S Fulton
What command line options do you use?
swig -c++ -python -classic -threads -outdir ../ -v CppBlockUtils.i
This change is due to https://github.com/swig/swig/pull/232. We don't
test for -classic, so this is probably why it slipped through.

I'd like to see it fixed for the release I was hoping to put out today
if anyone can shed any light on this it will be helpful.

William
William S Fulton
2015-01-31 01:49:10 UTC
Permalink
Post by William S Fulton
Post by Douglas Roark
On Wed, Jan 28, 2015 at 1:07 AM, William S Fulton
Post by William S Fulton
What command line options do you use?
swig -c++ -python -classic -threads -outdir ../ -v CppBlockUtils.i
This change is due to https://github.com/swig/swig/pull/232. We don't
test for -classic, so this is probably why it slipped through.
I'd like to see it fixed for the release I was hoping to put out today
if anyone can shed any light on this it will be helpful.
I've fixed this now in master. Please test if you can. I'll probably
make the swig-3.0.5 release tomorrow and it will include this fix.

William
William S Fulton
2015-01-31 01:55:32 UTC
Permalink
Post by Douglas Roark
swig -c++ -python -classic -threads -outdir ../ -v CppBlockUtils.i
BTW, what is the reason for using -classic? I'm actually wondering if
we should deprecate this option.

William
Douglas Roark
2015-01-31 19:56:06 UTC
Permalink
On Fri, Jan 30, 2015 at 8:55 PM, William S Fulton
Post by William S Fulton
Post by Douglas Roark
swig -c++ -python -classic -threads -outdir ../ -v CppBlockUtils.i
BTW, what is the reason for using -classic? I'm actually wondering if
we should deprecate this option.
Thanks for the fix. I'll try it as soon as I get a chance and report back.

As for the -classic option, I asked the guy who originally wrote the
software. He couldn't remember the exact reason. He was pretty sure it
had to do with segfaults, or may iterating C++ STL containers, or
both. He started around July 2011, so he was probably using SWIG 2.0.3
or 2.0.4 at the time. My guess is that there was a bug that was
eventually fixed, and he never went back and removed the option. Once
I have some free time, I'll remove the option and see what happens.
I'd be genuinely surprised if the original problem still exists.

As for whether or not -classic should be deprecated, that's your call.
:) We have no real attachment to the option other than it once served
a purpose. If that purpose is no longer valid, we're happy to chuck
the option.

Thanks.

Doug
Douglas Roark
2015-02-01 20:56:28 UTC
Permalink
On Fri, Jan 30, 2015 at 8:49 PM, William S Fulton
Post by William S Fulton
Post by William S Fulton
This change is due to https://github.com/swig/swig/pull/232. We don't
test for -classic, so this is probably why it slipped through.
I'd like to see it fixed for the release I was hoping to put out today
if anyone can shed any light on this it will be helpful.
I've fixed this now in master. Please test if you can. I'll probably
make the swig-3.0.5 release tomorrow and it will include this fix.
I tested just now. 3.0.5 works. Thanks!

(Just to reiterate, my team has no real attachment to -classic other
than, at some point 2-3 years ago, it fixed fatal bugs that the
community knew about. I'm already planning on removing it after our
next release goes out the door.)

Doug

William S Fulton
2015-01-28 19:48:30 UTC
Permalink
Post by Douglas Roark
Hello. I think I've found a regression bug in the latest version of
SWIG. I'm running it on some code on OS X. I get the following error
when I try to run my program.
---
File "CppBlockUtils.py", line 4075, in <lambda>
__setattr__ = lambda self, name, value: _swig_setattr(self,
BDM_CallBack, name, value)
File "CppBlockUtils.py", line 51, in _swig_setattr
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
File "CppBlockUtils.py", line 45, in _swig_setattr_nondynamic
object.__setattr__(self, name, value)
---
What is the error message that you have chopped off at the end of this
stack trace? Also, how do you get this? Is it a director class? A
simple bit of C++ and what you are calling in Python would help.

William
Douglas Roark
2015-01-29 01:31:28 UTC
Permalink
On Wed, Jan 28, 2015 at 2:48 PM, William S Fulton
Post by William S Fulton
What is the error message that you have chopped off at the end of this
stack trace? Also, how do you get this? Is it a director class? A
simple bit of C++ and what you are calling in Python would help.
Here's the full trace. I see this on the command line when the
(Python) program chokes. Note that I've shortened the paths greatly.
If you wish to view the codebase,
https://github.com/etotheipi/BitcoinArmory/commits/0.93-bugfix is the
link.

Traceback (most recent call last):
File "ArmoryQt.py", line 40, in <module>
from announcefetch import AnnounceDataFetcher, ANNOUNCE_URL,
ANNOUNCE_URL_BACKUP, \
File "announcefetch.py", line 8, in <module>
from armoryengine.ALL import *
File "armoryengine/ALL.py", line 10, in <module>
from armoryengine.BDM import *
File "armoryengine/BDM.py", line 413, in <module>
TheBDM = BlockDataManager(isOffline=False)
File "armoryengine/BDM.py", line 163, in __init__
self.callback = PySide_CallBack(self).__disown__()
File "armoryengine/BDM.py", line 43, in __init__
self.bdm = bdm
File "CppBlockUtils.py", line 4075, in <lambda>
__setattr__ = lambda self, name, value: _swig_setattr(self,
BDM_CallBack, name, value)
File "CppBlockUtils.py", line 51, in _swig_setattr
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
File "CppBlockUtils.py", line 45, in _swig_setattr_nondynamic
object.__setattr__(self, name, value)
TypeError: can't apply this __setattr__ to instance object

Thanks.

Doug
Loading...