Commit 47289b58 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[exceptions] stop catching any exception in various places (closes #1942716)

--HG--
branch : stable
parent 1ec9fe1dfba9
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
......@@ -241,7 +241,7 @@ class MultiSelector(Selector):
for selector in selectors:
try:
selector = _instantiate_selector(selector)
except:
except Exception:
pass
#assert isinstance(selector, Selector), selector
if isinstance(selector, cls):
......
......@@ -618,7 +618,7 @@ this option is set to yes",
try:
__import__('cubes.%s.ccplugin' % cube)
cls.info('loaded cubicweb-ctl plugin from %s', cube)
except:
except Exception:
cls.exception('while loading plugin %s', pluginfile)
elif exists(oldpluginfile):
warn('[3.6] %s: ecplugin module should be renamed to ccplugin' % cube,
......@@ -626,12 +626,12 @@ this option is set to yes",
try:
__import__('cubes.%s.ecplugin' % cube)
cls.info('loaded cubicweb-ctl plugin from %s', cube)
except:
except Exception:
cls.exception('while loading plugin %s', oldpluginfile)
elif exists(initfile):
try:
__import__('cubes.%s' % cube)
except:
except Exception:
cls.exception('while loading cube %s', cube)
else:
cls.warning('no __init__ file in cube %s', cube)
......
......@@ -554,7 +554,7 @@ class StopInstanceCommand(InstanceCommand):
pid = int(open(pidf).read().strip())
try:
kill(pid, signal.SIGTERM)
except:
except Exception:
print >> sys.stderr, "process %s seems already dead." % pid
else:
try:
......@@ -564,7 +564,7 @@ class StopInstanceCommand(InstanceCommand):
print >> sys.stderr, 'trying SIGKILL'
try:
kill(pid, signal.SIGKILL)
except:
except Exception:
# probably dead now
pass
wait_process_end(pid)
......
......@@ -554,7 +554,7 @@ class CWImportController(object):
self.tell("Run import function '%s'..." % func_name)
try:
func(self)
except:
except Exception:
if self.catcherrors:
self.record_error(func_name, 'While calling %s' % func.__name__)
else:
......
......@@ -301,7 +301,7 @@ class DBAPIRequest(RequestSessionBase):
def set_default_language(self, vreg):
try:
self.lang = vreg.property_value('ui.language')
except: # property may not be registered
except Exception: # property may not be registered
self.lang = 'en'
# use req.__ to translate a message without registering it to the catalog
try:
......@@ -532,7 +532,7 @@ class Connection(object):
if self._closed is None and self._close_on_del:
try:
self.close()
except:
except Exception:
pass
# connection initialization methods ########################################
......
......@@ -577,7 +577,7 @@ class PostgresTestDataBaseHandler(TestDataBaseHandler):
templcursor.close()
cnx.close()
init_repository(self.config, interactive=False)
except:
except BaseException:
if self.dbcnx is not None:
self.dbcnx.rollback()
print >> sys.stderr, 'building', self.dbname, 'failed'
......@@ -752,13 +752,13 @@ def install_sqlite_patch(querier):
value = value.rsplit('.', 1)[0]
try:
row[cellindex] = strptime(value, '%Y-%m-%d %H:%M:%S')
except:
except Exception:
row[cellindex] = strptime(value, '%Y-%m-%d')
if vtype == 'Time' and type(value) is unicode:
found_date = True
try:
row[cellindex] = strptime(value, '%H:%M:%S')
except:
except Exception:
# DateTime used as Time?
row[cellindex] = strptime(value, '%Y-%m-%d %H:%M:%S')
if vtype == 'Interval' and type(value) is int:
......
......@@ -352,7 +352,7 @@ def select(constraints, cursor, selectvar='O', objtype=None):
if objtype:
rql += ', %s is %s' % (selectvar, objtype)
rset = cursor.execute(rql)
except:
except Exception:
print "could restrict eid_list with given constraints (%r)" % constraints
return []
return set(eid for eid, in rset.rows)
......
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
......@@ -38,7 +38,7 @@ OPTIONS:
-o / --report-output <filename>
Write profiler report into <filename> rather than on stdout
Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
Copyright (c) 2003-2011 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
......@@ -73,9 +73,7 @@ class QueryExecutor:
start = clock()
try:
cursor.execute(query)
except KeyboardInterrupt:
raise
except:
except Exception:
TB_LOCK.acquire()
traceback.print_exc()
TB_LOCK.release()
......
......@@ -233,7 +233,7 @@ class CubicWebTC(TestCase):
# web resources
try:
config.global_set_option('embed-allowed', re.compile('.*'))
except: # not in server only configuration
except Exception: # not in server only configuration
pass
#XXX this doesn't need to a be classmethod anymore
......@@ -812,15 +812,13 @@ class CubicWebTC(TestCase):
"""
try:
output = viewfunc(**kwargs)
except (SystemExit, KeyboardInterrupt):
raise
except:
except Exception:
# hijack exception: generative tests stop when the exception
# is not an AssertionError
klass, exc, tcbk = sys.exc_info()
try:
msg = '[%s in %s] %s' % (klass, view.__regid__, exc)
except:
except Exception:
msg = '[%s in %s] undisplayable exception' % (klass, view.__regid__)
raise AssertionError, msg, tcbk
return self._check_html(output, view, template)
......@@ -862,9 +860,7 @@ class CubicWebTC(TestCase):
def assertWellFormed(self, validator, content, context=None):
try:
return validator.parse_string(content)
except (SystemExit, KeyboardInterrupt):
raise
except:
except Exception:
# hijack exception: generative tests stop when the exception
# is not an AssertionError
klass, exc, tcbk = sys.exc_info()
......@@ -876,7 +872,7 @@ class CubicWebTC(TestCase):
try:
str_exc = str(exc)
except:
except Exception:
str_exc = 'undisplayable exception'
msg += str_exc
if content is not None:
......@@ -1179,7 +1175,7 @@ def vreg_instrumentize(testclass):
reg._selected = {}
try:
orig_select_best = reg.__class__.__orig_select_best
except:
except Exception:
orig_select_best = reg.__class__._select_best
def instr_select_best(self, *args, **kwargs):
selected = orig_select_best(self, *args, **kwargs)
......
......@@ -102,7 +102,7 @@ def parse_js_files(args=sys.argv):
for fileid in INDEX_IN_ORDER:
try:
index.remove(fileid)
except:
except Exception:
raise Exception(
'Bad file id %s referenced in INDEX_IN_ORDER in %s, '
'fix this please' % (fileid, __file__))
......
# copyright 2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2010-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
......@@ -137,7 +137,7 @@ class IFTIndexableAdapter(EntityAdapter):
value = entity.printable_value(rschema, format='text/plain')
except TransformError:
continue
except:
except Exception:
self.exception("can't add value of %s to text index for entity %s",
rschema, entity.eid)
continue
......
......@@ -98,7 +98,7 @@ class CWUser(AnyEntity):
prop = self._cw.execute(
'CWProperty X WHERE X pkey %(k)s, X for_user U, U eid %(u)s',
{'k': pkey, 'u': self.eid}).get_entity(0, 0)
except:
except Exception:
kwargs = dict(pkey=unicode(pkey), value=value)
if self.is_in_group('managers'):
kwargs['for_user'] = self
......
......@@ -308,7 +308,7 @@ class CubicWebRootResource(resource.Resource):
# so we deferred that part to the cubicweb thread
request.process_multipart()
return self._render_request(request)
except:
except Exception:
errorstream = StringIO()
traceback.print_exc(file=errorstream)
return HTTPResponse(stream='<pre>%s</pre>' % errorstream.getvalue(),
......
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
......@@ -71,7 +71,7 @@ def eid_reference_role(role, rawtext, text, lineno, inliner,
try:
try:
eid_num, rest = text.split(u':', 1)
except:
except ValueError:
eid_num, rest = text, '#'+text
eid_num = int(eid_num)
if eid_num < 0:
......
......@@ -191,7 +191,7 @@ class EntityDeleteHook(SomethingChangedHook):
def _call(self):
try:
title = self.entity.dc_title()
except:
except Exception:
# may raise an error during deletion process, for instance due to
# missing required relation
title = '#%s' % self.entity.eid
......
......@@ -87,7 +87,7 @@ def add_inline_relation_column(session, etype, rtype):
session.system_sql(str('ALTER TABLE %s ADD %s integer'
% (table, column)), rollback_on_failure=False)
session.info('added column %s to table %s', column, table)
except:
except Exception:
# silent exception here, if this error has not been raised because the
# column already exists, index creation will fail anyway
session.exception('error while adding column %s to table %s',
......@@ -221,8 +221,8 @@ class MemSchemaNotifyChanges(hook.SingleLastOperation):
cwuser_cls = self.session.vreg['etypes'].etype_class('CWUser')
for session in repo._sessions.values():
session.user.__class__ = cwuser_cls
except:
self.critical('error while setting schmea', exc_info=True)
except Exception:
self.critical('error while setting schema', exc_info=True)
def rollback_event(self):
self.precommit_event()
......
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
......@@ -182,7 +182,7 @@ class SchemaModificationHooksTC(CubicWebTC):
self.failIf(self.index_exists('State', 'state_of'))
rset = self.execute('Any X, Y WHERE X state_of Y')
self.assertEqual(len(rset), 2) # user states
except:
except Exception:
import traceback
traceback.print_exc()
finally:
......
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
......@@ -67,7 +67,7 @@ def parse_message_id(msgid, appid):
values = b64decode(str(values + '='*padding), '.-')
values = dict(v.split('=') for v in values.split('&'))
fromappid, host = qualif.split('.', 1)
except:
except Exception:
return None
if appid != fromappid or host != gethostname():
return None
......
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
......@@ -488,7 +488,7 @@ class ConfigurationProblem(object):
try:
oper, version = constraint.split()
self.reverse_dependencies[name].add( (oper, version, cube) )
except:
except Exception:
self.warnings.append(
'cube %s depends on %s but constraint badly '
'formatted: %s' % (cube, name, constraint))
......
......@@ -15,9 +15,6 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""
"""
import webbrowser
reload(webbrowser)
......@@ -89,7 +86,7 @@ class RQLSensor(Sensor):
cursor = cnx.cursor()
try:
rset = cursor.execute(rql)
except:
except Exception:
del self._v_cnx
raise
self._urls = []
......@@ -101,7 +98,7 @@ class RQLSensor(Sensor):
output.set('resultbg[%s]' % i, 'black')
try:
self._urls.append(base % 'Any X WHERE X eid %s' % line[0])
except:
except Exception:
self._urls.append('')
i += 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment