hush somewhat-real problems found by static analysis

These would have caused problems if a certain unlikely code path was taken:
mostly error-handling pathways.
This commit is contained in:
Brian Warner 2017-12-31 00:23:43 +01:00
parent da4e7dcfbe
commit 5e62118e14
4 changed files with 6 additions and 5 deletions

View File

@ -62,7 +62,7 @@ def check_loop(ast, results):
# contains another 'for' loop.
childnodes = funcnode.getChildNodes()[len(funcnode.defaults):]
for child in childnodes:
check_ast(funcnode, results)
check_ast(child, results)
def collect_assigned_and_nested(ast, assigned, nested):
"""

View File

@ -243,7 +243,7 @@ class MagicFolder(service.MultiService):
clock = clock or reactor
db = magicfolderdb.get_magicfolderdb(dbfile, create_version=(magicfolderdb.SCHEMA_v1, 1))
if db is None:
return Failure(Exception('ERROR: Unable to load magic folder db.'))
raise Exception('ERROR: Unable to load magic folder db.')
# for tests
self._client = client

View File

@ -32,7 +32,7 @@ class BadResponse(object):
self.status = -1
self.reason = "Error trying to connect to %s: %s" % (url, err)
self.error = err
def read(self):
def read(self, length=0):
return ""

View File

@ -36,10 +36,11 @@ class LogMixin(object):
def log(self, msg, facility=None, parent=None, *args, **kwargs):
if facility is None:
facility = self._facility
pmsgid = None
if parent is None:
pmsgid = self._parentmsgid
if pmsgid is None:
pmsgid = self._grandparentmsgid
if pmsgid is None:
pmsgid = self._grandparentmsgid
msgid = log.msg(msg, facility=facility, parent=pmsgid, *args, **kwargs)
if self._parentmsgid is None:
self._parentmsgid = msgid