Menu

#161 SQLObject uses assert for parameter checks

open
nobody
General (125)
5
2013-01-18
2006-03-08
No

SQLObject uses some assert statements to make sure the
classes were given correct parameters or called correctly.

For example, in dbconnection.py

def uri(self):
auth = getattr(self, 'user', None) or ''
if auth:
if self.password:
auth = auth + '@' + self.password
auth = auth + ':'
else:
>>> assert not getattr(self, 'password',
None), (
>>> 'URIs cannot express passwords
without usernames')

or

assert not self._obsolete, "This transaction has
already gone through ROLLBACK; begin another transaction"

The problem with these constructs is that if SQLObject
is compiled with -O (which, for example Debian does),
asserts are removed!

So I can import sqlobject and happily pass incorrect
values, it will not be noticed.

Discussion


Log in to post a comment.