- attached sa-bug.tar.gz
work around Python bug #1569356
Under some circumstances, SQLAlchemy replaces instances of my declarative_base()-based class by one of 'propertyProxy' - which is originally defined as ''Proxy'' (you can verify this information by inserting ''raise self.!doc!'' in model.Member._set_password()).
I don't know the exact circumstances under which this occurs, but I know that running my test suite via a Continuous Integration System (such as Bitten) is one of them.
So I have created the minimum files required to reproduce the bug with Bitten, which I have attached as a compressed file. Please decompress the attached file and run:
# You may want to use a virtualenv for this.
# Installing Bitten:
easy_install http://svn.edgewall.org/repos/bitten/trunk/
# This has been tested with 0.5beta3:
easy_install "SQLAlchemy==0.5beta3"
# Now run my test suite via Bitten:
bitten-slave --keep-files --build-dir $PWD bitten-recipe.xml
You will get this error:
[ ](INFO) Traceback (most recent call last):
[ ](INFO) File "/home/gustavo/Desktop/sa-bug/tests.py", line 36, in setUp
[ ](INFO) self.member = Member(u"ignucius", u"hello world")
[ ](INFO) File "<string>", line 4, in __init__
[ ](INFO) File "/home/gustavo/System/Pyenvs/tg2env/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/attributes.py", line 789, in initialize_instance
[ ](INFO) fn(self, instance, args, kwargs)
[ ](INFO) File "/home/gustavo/System/Pyenvs/tg2env/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/mapper.py", line 1628, in _event_on_init
[ ](INFO) instrumenting_mapper.compile()
[ ](INFO) File "/home/gustavo/System/Pyenvs/tg2env/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/mapper.py", line 369, in compile
[ ](INFO) mapper.__initialize_properties()
[ ](INFO) File "/home/gustavo/System/Pyenvs/tg2env/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/mapper.py", line 390, in __initialize_properties
[ ](INFO) prop.init(key, self)
[ ](INFO) File "/home/gustavo/System/Pyenvs/tg2env/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/interfaces.py", line 384, in init
[ ](INFO) self.do_init()
[ ](INFO) File "/home/gustavo/System/Pyenvs/tg2env/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/properties.py", line 196, in do_init
[ ](INFO) strategies.DefaultColumnLoader(self)._register_attribute(None, None, False, comparator_callable, proxy_property=self.descriptor)
[ ](INFO) File "/home/gustavo/System/Pyenvs/tg2env/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/strategies.py", line 39, in _register_attribute
[ ](INFO) proxy_property=proxy_property
[ ](INFO) File "/home/gustavo/System/Pyenvs/tg2env/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 85, in register_attribute
[ ](INFO) return attributes.register_attribute(class_, key, *args, **kwargs)
[ ](INFO) File "/home/gustavo/System/Pyenvs/tg2env/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/attributes.py", line 1429, in register_attribute
[ ](INFO) descriptor = proxy_type(key, proxy_property, comparator, parententity)
[ ](INFO) File "/home/gustavo/System/Pyenvs/tg2env/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3-py2.5.egg/sqlalchemy/orm/attributes.py", line 159, in __init__
[ ](INFO) self.descriptor = self.user_prop = descriptor
[ ](INFO) File "/home/gustavo/Desktop/sa-bug/model.py", line 54, in _set_password
[ ](INFO) self._password = self.__class__._calculate_hash(password)
[ ](INFO) AttributeError: type object 'propertyProxy' has no attribute '_calculate_hash'
However, you won't get this error if you run the test suite directly:
python setup.py test
Please notice that this is not caused by Bitten: - If you check the environment variables with the two commands above (bitten-slave and `setup.py test'), you will find that they all have the same contents. - Bitten doesn't do anything special, it just runs distutils to run the ''test'' command.
Finally, please notice that I'm getting this error since I'm using ''synonym'' - everything was perfect before.
Comments (6)
-
Account Deleted -
Account Deleted -
repo owner - changed status to wontfix
the bug is in bitten. Remove model.py and replace tests.py with simply this code:
def foo(somearg): class Bar(object): def __getattr__(self, attribute): return getattr(somearg, attribute) assert 'somearg' not in Bar.__dict__ foo('hi')
run the bitten commandline, and it fails.
Please report this as a bug on the Bitten tracker.
-
repo owner - changed component to orm
- changed title to work around Python bug #1569356
- changed milestone to 0.5.xx
- removed status
- changed status to open
according to http://bugs.python.org/issue1569356, this is a Python bug that is only fixed in 2.6. We should try working around it for python 2.5.
-
repo owner -
repo owner - changed status to wontfix
time moves on and 2.6 is commonplace. closing this for now.
- Log in to comment
The files to reproduce this bug