]> git.notmuchmail.org Git - notmuch/commitdiff
python: Bulletproof Database() path parameter
authorSebastian Spaeth <Sebastian@SSpaeth.de>
Thu, 16 Jun 2011 13:51:13 +0000 (15:51 +0200)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Thu, 16 Jun 2011 13:51:13 +0000 (15:51 +0200)
libnotmuch (and python) crashed when I accidently passed in an invalid
value as path argument to the Database() instantiation.

Therefore, we now check via assert that the handed in path is actually a
real string (or None).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
bindings/python/notmuch/database.py

index 9016f0ae997d0cac1ea54af54e3fb04d71c9ee78..926bac63f5931882941238b866dc3b4ee5b14bc1 100644 (file)
@@ -100,6 +100,7 @@ class Database(object):
                 Database._std_db_path = self._get_user_default_db()
             path = Database._std_db_path
 
+        assert isinstance(path, basestring), 'Path needs to be a string or None.'
         if create == False:
             self.open(path, mode)
         else: