allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject [allura] 01/03: [#8373] B001 Do not use bare `except:`, it also catches unexpected events like memory errors, interrupts, system exit, and so on
Date Mon, 10 Aug 2020 12:57:26 GMT
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 0ac7c0840cfca26328c954aac08b31bdaf90cb4e
Author: Dave Brondsema <dave@brondsema.net>
AuthorDate: Fri Jul 31 14:35:04 2020 -0400

    [#8373] B001 Do not use bare `except:`, it also catches unexpected events like memory
errors, interrupts, system exit, and so on
---
 Allura/allura/command/show_models.py               |  2 +-
 Allura/allura/command/taskd.py                     |  2 +-
 Allura/allura/config/app_cfg.py                    |  2 +-
 Allura/allura/controllers/site_admin.py            |  2 +-
 Allura/allura/lib/helpers.py                       |  2 +-
 Allura/allura/lib/mail_util.py                     |  2 +-
 Allura/allura/lib/patches.py                       |  2 +-
 Allura/allura/lib/plugin.py                        | 63 +++++++++++-----------
 Allura/allura/lib/validators.py                    |  8 +--
 Allura/allura/model/artifact.py                    |  2 +-
 Allura/allura/model/auth.py                        |  2 +-
 Allura/allura/model/index.py                       |  2 +-
 Allura/allura/model/notification.py                | 10 ++--
 Allura/allura/model/session.py                     |  2 +-
 Allura/allura/scripts/refresh_last_commits.py      |  2 +-
 Allura/allura/scripts/refreshrepo.py               |  2 +-
 Allura/allura/tasks/event_tasks.py                 |  2 +-
 Allura/allura/tasks/export_tasks.py                |  2 +-
 Allura/allura/tasks/mail_tasks.py                  |  4 +-
 Allura/allura/tasks/repo_tasks.py                  |  2 +-
 Allura/allura/tests/test_tasks.py                  |  2 +-
 Allura/allura/webhooks.py                          |  2 +-
 Allura/allura/websetup/bootstrap.py                |  4 +-
 AlluraTest/alluratest/controller.py                |  2 +-
 ForgeDiscussion/forgediscussion/forum_main.py      |  2 +-
 ForgeDiscussion/forgediscussion/import_support.py  |  2 +-
 ForgeGit/forgegit/model/git_repo.py                |  4 +-
 ForgeGit/forgegit/tests/functional/test_auth.py    |  2 +-
 ForgeSVN/forgesvn/model/svn.py                     |  2 +-
 ForgeTracker/forgetracker/import_support.py        |  2 +-
 ForgeTracker/forgetracker/model/ticket.py          |  2 +-
 ForgeTracker/forgetracker/tracker_main.py          |  2 +-
 fuse/accessfs.py                                   |  2 +-
 .../032-subscribe-merge-request-submitters.py      |  2 +-
 scripts/teamforge-import.py                        |  6 +--
 scripts/wiki-copy.py                               |  2 +-
 36 files changed, 77 insertions(+), 80 deletions(-)

diff --git a/Allura/allura/command/show_models.py b/Allura/allura/command/show_models.py
index b1bed1f..f4623de 100644
--- a/Allura/allura/command/show_models.py
+++ b/Allura/allura/command/show_models.py
@@ -131,7 +131,7 @@ class ReindexCommand(base.Command):
                             try:
                                 M.ArtifactReference.from_artifact(a)
                                 M.Shortlink.from_artifact(a)
-                            except:
+                            except Exception:
                                 base.log.exception(
                                     'Making ArtifactReference/Shortlink from %s', a)
                                 continue
diff --git a/Allura/allura/command/taskd.py b/Allura/allura/command/taskd.py
index 908a45e..1f5ec78 100644
--- a/Allura/allura/command/taskd.py
+++ b/Allura/allura/command/taskd.py
@@ -51,7 +51,7 @@ def proctitle(title):
         setproctitle(title)
         yield
         setproctitle(orig_title)
-    except:
+    except Exception:
         setproctitle(orig_title)
         raise
 
diff --git a/Allura/allura/config/app_cfg.py b/Allura/allura/config/app_cfg.py
index f795f2c..58f3a75 100644
--- a/Allura/allura/config/app_cfg.py
+++ b/Allura/allura/config/app_cfg.py
@@ -93,7 +93,7 @@ class AlluraJinjaRenderer(JinjaRenderer):
             elif cache_type == 'filesystem':
                 from jinja2 import FileSystemBytecodeCache
                 bcc = FileSystemBytecodeCache(pattern='__jinja2_{}_%s.cache'.format(jinja2.__version__))
-        except:
+        except Exception:
             log.exception("Error encountered while setting up a" +
                           " %s-backed bytecode cache for Jinja" % cache_type)
         return bcc
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 23e1398..530297b 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -164,7 +164,7 @@ class SiteAdminController(object):
 
             try:
                 ok = self.subscribe_artifact(url, user)
-            except:
+            except Exception:
                 log.warn("Can't subscribe to artifact", exc_info=True)
                 ok = False
 
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 6b29822..1bcff39 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -685,7 +685,7 @@ def twophase_transaction(*engines):
             to_rollback.append(txn)
         for txn in txns:
             txn.commit()
-    except:
+    except Exception:
         for txn in to_rollback:
             txn.rollback()
         raise
diff --git a/Allura/allura/lib/mail_util.py b/Allura/allura/lib/mail_util.py
index bdde46c..9d61333 100644
--- a/Allura/allura/lib/mail_util.py
+++ b/Allura/allura/lib/mail_util.py
@@ -295,7 +295,7 @@ class SMTPClient(object):
                 config.return_path,
                 smtp_addrs,
                 content)
-        except:
+        except Exception:
             self._connect()
             self._client.sendmail(
                 config.return_path,
diff --git a/Allura/allura/lib/patches.py b/Allura/allura/lib/patches.py
index 9f4e5fa..7080fa4 100644
--- a/Allura/allura/lib/patches.py
+++ b/Allura/allura/lib/patches.py
@@ -43,7 +43,7 @@ def apply():
         '''Wrapper to handle totally borked-up HTTP-ACCEPT headers'''
         try:
             return old_lookup_template_engine(self, request)
-        except:
+        except Exception:
             pass
         environ = dict(request.environ, HTTP_ACCEPT='*/*')
         request = webob.Request(environ)
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 2a804f0..821a3f6 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -665,39 +665,36 @@ class LdapAuthenticationProvider(AuthenticationProvider):
 
         # full registration into LDAP
         uid = str(M.AuthGlobals.get_next_uid()).encode('utf-8')
+        con = ldap_conn()
+        uname = user_doc['username'].encode('utf-8')
+        display_name = user_doc['display_name'].encode('utf-8')
+        ldif_u = modlist.addModlist(dict(
+            uid=uname,
+            userPassword=self._encode_password(user_doc['password']),
+            objectClass=[b'account', b'posixAccount'],
+            cn=display_name,
+            uidNumber=uid,
+            gidNumber=b'10001',
+            homeDirectory=b'/home/' + uname,
+            loginShell=b'/bin/bash',
+            gecos=uname,
+            description=b'SCM user account'))
         try:
-            con = ldap_conn()
-            uname = user_doc['username'].encode('utf-8')
-            display_name = user_doc['display_name'].encode('utf-8')
-            ldif_u = modlist.addModlist(dict(
-                uid=uname,
-                userPassword=self._encode_password(user_doc['password']),
-                objectClass=[b'account', b'posixAccount'],
-                cn=display_name,
-                uidNumber=uid,
-                gidNumber=b'10001',
-                homeDirectory=b'/home/' + uname,
-                loginShell=b'/bin/bash',
-                gecos=uname,
-                description=b'SCM user account'))
-            try:
-                con.add_s(ldap_user_dn(user_doc['username']), ldif_u)
-            except ldap.ALREADY_EXISTS:
-                log.exception('Trying to create existing user %s', uname)
-                raise
-            con.unbind_s()
-
-            if asbool(config.get('auth.ldap.use_schroot', True)):
-                argv = ('schroot -d / -c %s -u root /ldap-userconfig.py init %s' % (
-                    config['auth.ldap.schroot_name'], user_doc['username'])).split()
-                p = subprocess.Popen(
-                    argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-                rc = p.wait()
-                if rc != 0:
-                    log.error('Error creating home directory for %s',
-                              user_doc['username'])
-        except:
+            con.add_s(ldap_user_dn(user_doc['username']), ldif_u)
+        except ldap.ALREADY_EXISTS:
+            log.exception('Trying to create existing user %s', uname)
             raise
+        con.unbind_s()
+
+        if asbool(config.get('auth.ldap.use_schroot', True)):
+            argv = ('schroot -d / -c %s -u root /ldap-userconfig.py init %s' % (
+                config['auth.ldap.schroot_name'], user_doc['username'])).split()
+            p = subprocess.Popen(
+                argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+            rc = p.wait()
+            if rc != 0:
+                log.error('Error creating home directory for %s',
+                          user_doc['username'])
         return result
 
     def upload_sshkey(self, username, pubkey):
@@ -713,7 +710,7 @@ class LdapAuthenticationProvider(AuthenticationProvider):
             errmsg = p.stdout.read()
             log.exception('Error uploading public SSH key for %s: %s',
                           username, errmsg)
-            assert False, errmsg
+            raise AssertionError(errmsg)
 
     def _get_salt(self, length):
         def random_char():
@@ -948,7 +945,7 @@ class ProjectRegistrationProvider(object):
                 apps=[
                     ('Wiki', 'wiki', 'Wiki'),
                     ('admin', 'admin', 'Admin')])
-        except:
+        except Exception:
             ThreadLocalORMSession.close_all()
             log.exception('Error registering project %s' % p)
             raise
diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index 37e6cb2..9dd0c91 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -95,7 +95,7 @@ class Ming(fev.FancyValidator):
         if result is None:
             try:
                 result = self.cls.query.get(_id=ObjectId(value))
-            except:
+            except Exception:
                 pass
         return result
 
@@ -320,7 +320,7 @@ class UserMapJsonFile(JsonFile):
                 if not(isinstance(k, six.string_types) and isinstance(v, six.string_types)):
                     raise
             return json.dumps(value) if self.as_string else value
-        except:
+        except Exception:
             raise fe.Invalid(
                 'User map file must contain mapping of {str:str, ...}',
                 value, state)
@@ -439,7 +439,7 @@ def convertDate(datestring):
         try:
             date = datetime.strptime(datestring, f)
             return date
-        except:
+        except Exception:
             pass
     return None
 
@@ -451,7 +451,7 @@ def convertTime(timestring):
         try:
             time = datetime.strptime(timestring, f)
             return {'h': time.hour, 'm': time.minute}
-        except:
+        except Exception:
             pass
     return None
 
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index cc98b45..614eb0a 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -579,7 +579,7 @@ class VersionedArtifact(Artifact):
         '''Save off a snapshot of the artifact and increment the version #'''
         try:
             ip_address = utils.ip_address(request)
-        except:
+        except Exception:
             ip_address = '0.0.0.0'
         data = dict(
             artifact_id=self._id,
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index c8b3cd8..10c6550 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -612,7 +612,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         icon_url = None
         try:
             private_project = self.private_project()
-        except:
+        except Exception:
             log.warn('Error getting/creating user-project for %s',
                      self.username, exc_info=True)
             private_project = None
diff --git a/Allura/allura/model/index.py b/Allura/allura/model/index.py
index e22c8da..146e82a 100644
--- a/Allura/allura/model/index.py
+++ b/Allura/allura/model/index.py
@@ -102,7 +102,7 @@ class ArtifactReference(object):
             cls = loads(six.binary_type(aref.cls))
             with h.push_context(aref.project_id):
                 return cls.query.get(_id=aref.artifact_id)
-        except:
+        except Exception:
             log.exception('Error loading artifact for %s: %r',
                           self._id, aref)
 
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index 1b8ee27..bff46ec 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -231,7 +231,7 @@ class Notification(MappedClass):
                                          config=config, data=artifact, post=post, h=h))
         except jinja2.TemplateNotFound:
             pass
-        except:
+        except Exception:
             ''' Catch any errors loading or rendering the template,
             but the notification still gets sent if there is an error
             '''
@@ -559,7 +559,7 @@ class Mailbox(MappedClass):
                      })
                 # Make sure the mbox doesn't stick around to be flush()ed
                 session(mbox).expunge(mbox)
-            except:
+            except Exception:
                 # log error but try to keep processing, lest all the other eligible
                 # mboxes for this notification get skipped and lost forever
                 log.exception(
@@ -596,7 +596,7 @@ class Mailbox(MappedClass):
         for mbox in take_while_true(find_and_modify_direct_mbox):
             try:
                 mbox.fire(now)
-            except:
+            except Exception:
                 log.exception(
                     'Error firing mbox: %s with queue: [%s]', str(mbox._id), ', '.join(mbox.queue))
                 # re-raise so we don't keep (destructively) trying to process
@@ -648,7 +648,7 @@ class Mailbox(MappedClass):
                         key = (n.subject, n.from_address,
                                n.reply_to_address, n.author_id)
                         ngroups[key].append(n)
-                except:
+                except Exception:
                     # log error but keep trying to deliver other notifications,
                     # lest the other notifications (which have already been removed
                     # from the mobx's queue in mongo) be lost
@@ -663,7 +663,7 @@ class Mailbox(MappedClass):
                     else:
                         Notification.send_digest(
                             self.user_id, from_address, subject, ns, reply_to_address)
-                except:
+                except Exception:
                     # log error but keep trying to deliver other notifications,
                     # lest the other notifications (which have already been removed
                     # from the mobx's queue in mongo) be lost
diff --git a/Allura/allura/model/session.py b/Allura/allura/model/session.py
index 1b44c48..0203822 100644
--- a/Allura/allura/model/session.py
+++ b/Allura/allura/model/session.py
@@ -95,7 +95,7 @@ class IndexerSessionExtension(ManagedSessionExtension):
             try:
                 if arg:
                     task.post(arg)
-            except:
+            except Exception:
                 log.error('Error calling %s', task.__name__)
 
     def after_flush(self, obj=None):
diff --git a/Allura/allura/scripts/refresh_last_commits.py b/Allura/allura/scripts/refresh_last_commits.py
index 179317c..57f18e9 100644
--- a/Allura/allura/scripts/refresh_last_commits.py
+++ b/Allura/allura/scripts/refresh_last_commits.py
@@ -127,7 +127,7 @@ class RefreshLastCommits(ScriptTask):
                         new_commit_ids = app.repo.unknown_commit_ids()
                         if len(new_commit_ids) > 0:
                             refresh.post()
-                    except:
+                    except Exception:
                         log.exception('Error refreshing %r', c.app.repo)
                         raise
                     finally:
diff --git a/Allura/allura/scripts/refreshrepo.py b/Allura/allura/scripts/refreshrepo.py
index 7144541..d117138 100644
--- a/Allura/allura/scripts/refreshrepo.py
+++ b/Allura/allura/scripts/refreshrepo.py
@@ -122,7 +122,7 @@ class RefreshRepo(ScriptTask):
                         else:
                             c.app.repo.refresh(
                                 options.all, notify=options.notify, commits_are_new=options.commits_are_new)
-                    except:
+                    except Exception:
                         log.exception('Error refreshing %r', c.app.repo)
             ThreadLocalORMSession.flush_all()
 
diff --git a/Allura/allura/tasks/event_tasks.py b/Allura/allura/tasks/event_tasks.py
index 11e04ce..7a21902 100644
--- a/Allura/allura/tasks/event_tasks.py
+++ b/Allura/allura/tasks/event_tasks.py
@@ -29,7 +29,7 @@ def event(event_type, *args, **kwargs):
     for t in event_handler.listeners[event_type]:
         try:
             t(event_type, *args, **kwargs)
-        except:
+        except Exception:
             exceptions.append(sys.exc_info())
     if exceptions:
         if len(exceptions) == 1:
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 9693e1a..a5b960c 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -109,7 +109,7 @@ class BulkExport(object):
                       app.project.shortname, exc_info=True)
             try:
                 os.remove(json_file)
-            except:
+            except Exception:
                 pass
             return None
         else:
diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py
index 779cd0f..c6da880 100644
--- a/Allura/allura/tasks/mail_tasks.py
+++ b/Allura/allura/tasks/mail_tasks.py
@@ -104,7 +104,7 @@ def route_email(
                             c.app.handle_message(userpart, msg)
             except exc.MailError as e:
                 log.error('Error routing email to %s: %s', addr, e)
-            except:
+            except Exception:
                 log.exception('Error routing mail to %s', addr)
 
 
@@ -173,7 +173,7 @@ def sendmail(fromaddr, destinations, text, reply_to, subject,
                 if not user:
                     log.warning('Cannot find user with ID: %s', addr)
                     continue
-            except:
+            except Exception:
                 log.exception('Error looking up user with ID: %r' % addr)
                 continue
             addr = user.email_address_header()
diff --git a/Allura/allura/tasks/repo_tasks.py b/Allura/allura/tasks/repo_tasks.py
index 04e1a9f..b47f562 100644
--- a/Allura/allura/tasks/repo_tasks.py
+++ b/Allura/allura/tasks/repo_tasks.py
@@ -142,7 +142,7 @@ def tarball(revision, path):
         else:
             try:
                 repo.tarball(revision, path)
-            except:
+            except Exception:
                 log.error(
                     'Could not create snapshot for repository: %s:%s revision %s path %s'
%
                     (c.project.shortname, c.app.config.options.mount_point, revision, path),
exc_info=True)
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index c2d9117..63b18ad 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -594,7 +594,7 @@ def raise_exc():
     for x in range(10):
         try:
             assert False, str('assert %d' % x)
-        except:
+        except Exception:
             errs.append(sys.exc_info())
     raise CompoundError(*errs)
 
diff --git a/Allura/allura/webhooks.py b/Allura/allura/webhooks.py
index c41d8c0..a5f0004 100644
--- a/Allura/allura/webhooks.py
+++ b/Allura/allura/webhooks.py
@@ -66,7 +66,7 @@ class WebhookValidator(fev.FancyValidator):
         else:
             try:
                 wh = M.Webhook.query.get(_id=ObjectId(value))
-            except:
+            except Exception:
                 pass
         if wh and wh.type == self.sender.type and wh.app_config_id == self.app.config._id:
             return wh
diff --git a/Allura/allura/websetup/bootstrap.py b/Allura/allura/websetup/bootstrap.py
index 9280175..a6d40d0 100644
--- a/Allura/allura/websetup/bootstrap.py
+++ b/Allura/allura/websetup/bootstrap.py
@@ -81,7 +81,7 @@ def bootstrap(command, conf, vars):
     wipe_database()
     try:
         g.solr.delete(q='*:*')
-    except:  # pragma no cover
+    except Exception:  # pragma no cover
         log.error('SOLR server is %s', g.solr_server)
         log.error('Error clearing solr index')
 
@@ -296,7 +296,7 @@ def wipe_database():
                 log.info('Dropping collection %s:%s', database, coll)
                 try:
                     db.drop_collection(coll)
-                except:
+                except Exception:
                     pass
 
 
diff --git a/AlluraTest/alluratest/controller.py b/AlluraTest/alluratest/controller.py
index 2da93da..918beb5 100644
--- a/AlluraTest/alluratest/controller.py
+++ b/AlluraTest/alluratest/controller.py
@@ -123,7 +123,7 @@ def setup_unit_test():
     try:
         while True:
             REGISTRY.cleanup()
-    except:
+    except Exception:
         pass
     REGISTRY.prepare()
     REGISTRY.register(ew.widget_context,
diff --git a/ForgeDiscussion/forgediscussion/forum_main.py b/ForgeDiscussion/forgediscussion/forum_main.py
index 5c6b19d..47c4735 100644
--- a/ForgeDiscussion/forgediscussion/forum_main.py
+++ b/ForgeDiscussion/forgediscussion/forum_main.py
@@ -198,7 +198,7 @@ class ForgeDiscussionApp(Application):
             l.append(
                 SitemapEntry('Formatting Help', c.app.url + 'markdown_syntax'))
             return l
-        except:  # pragma no cover
+        except Exception:  # pragma no cover
             log.exception('sidebar_menu')
             return []
 
diff --git a/ForgeDiscussion/forgediscussion/import_support.py b/ForgeDiscussion/forgediscussion/import_support.py
index cd8a334..8b4cadd 100644
--- a/ForgeDiscussion/forgediscussion/import_support.py
+++ b/ForgeDiscussion/forgediscussion/import_support.py
@@ -162,7 +162,7 @@ def create_user(json_username):
                 False)
             session(M.User).flush()
             break
-        except:
+        except Exception:
             raise
     return allura_username
 
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index d0982b8..11638f3 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -218,7 +218,7 @@ class GitImplementation(M.RepositoryImplementation):
                     bare=True)
             self.__dict__['_git'] = repo
             self._setup_special_files(source_url)
-        except:
+        except Exception:
             self._repo.set_status('ready')
             raise
 
@@ -236,7 +236,7 @@ class GitImplementation(M.RepositoryImplementation):
                 try:
                     from tg import request
                     url = ' at ' + request.url
-                except:
+                except Exception:
                     pass
                 log.exception('Error with rev_parse(%s)%s' %
                               (str(rev) + '^0', url))
diff --git a/ForgeGit/forgegit/tests/functional/test_auth.py b/ForgeGit/forgegit/tests/functional/test_auth.py
index 6c572e2..a329fbe 100644
--- a/ForgeGit/forgegit/tests/functional/test_auth.py
+++ b/ForgeGit/forgegit/tests/functional/test_auth.py
@@ -83,7 +83,7 @@ class TestGitUserPermissions(TestController):
             username=username), **kw)
         try:
             return r.json
-        except:
+        except Exception:
             return r
 
     @with_git
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 7a95b83..a01fdd4 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -431,7 +431,7 @@ class SVNImplementation(M.RepositoryImplementation):
                     id=self._tree_oid(commit._id, path),
                     name=path))
             else:
-                assert False
+                raise AssertionError()
             lcd_entries.append(dict(
                 name=path,
                 commit_id=self._oid(info.last_changed_rev.number),
diff --git a/ForgeTracker/forgetracker/import_support.py b/ForgeTracker/forgetracker/import_support.py
index efe011f..3a482c6 100644
--- a/ForgeTracker/forgetracker/import_support.py
+++ b/ForgeTracker/forgetracker/import_support.py
@@ -88,7 +88,7 @@ class ResettableStream(object):
     def seek(self, pos):
         self._read_header()
         if self.stream_pos > self.buf_len:
-            assert False, 'Started reading stream body, cannot reset pos'
+            raise AssertionError('Started reading stream body, cannot reset pos')
         self.buf.seek(pos)
         self.buf_pos = pos
 
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 99061c3..36b252f 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -1182,7 +1182,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
                     kwargs['posts_limit'] = posts_limit
                 try:
                     parents_json.update(parent.__json__(self, is_export=is_export, **kwargs))
-                except:
+                except Exception:
                     parents_json.update(parent.__json__(self, **kwargs))
 
         return dict(parents_json,
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 2aa2b0e..982a6ea 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -284,7 +284,7 @@ class ForgeTrackerApp(Application):
             ticket = TM.Ticket.query.get(
                 app_config_id=self.config._id,
                 ticket_num=int(topic))
-        except:
+        except Exception:
             log.exception('Error getting ticket %s', topic)
             return
         if not ticket:
diff --git a/fuse/accessfs.py b/fuse/accessfs.py
index 698693e..1f7b20d 100644
--- a/fuse/accessfs.py
+++ b/fuse/accessfs.py
@@ -328,7 +328,7 @@ class PermissionCache(object):
         uname = self._uid_cache.get(uid)
         try:
             entry = self._api_lookup(uname, path)
-        except:
+        except Exception:
             entry = 0
             log.exception('Error checking access for %s', path)
         self._save_result(uid, path, entry)
diff --git a/scripts/migrations/032-subscribe-merge-request-submitters.py b/scripts/migrations/032-subscribe-merge-request-submitters.py
index 66a7132..0430617 100644
--- a/scripts/migrations/032-subscribe-merge-request-submitters.py
+++ b/scripts/migrations/032-subscribe-merge-request-submitters.py
@@ -35,7 +35,7 @@ def main():
                 print('Processing {0}'.format(mr.url()))
                 mr.subscribe(user=mr.creator)
                 ThreadLocalORMSession.flush_all()
-            except:
+            except Exception:
                 log.exception('Error on %s', mr)
 
 
diff --git a/scripts/teamforge-import.py b/scripts/teamforge-import.py
index 44a4483..224d542 100644
--- a/scripts/teamforge-import.py
+++ b/scripts/teamforge-import.py
@@ -124,7 +124,7 @@ def main():
             return
         try:
             nbhd = M.Neighborhood.query.get(name=options.neighborhood)
-        except:
+        except Exception:
             log.exception('error querying mongo')
             log.error(
                 'This should be run as "paster script production.ini ../scripts/teamforge-import.py
-- ...options.."')
@@ -164,13 +164,13 @@ def main():
                     check_unsupported_tools(project)
                 with codecs.open(os.path.join(options.output_dir, 'users.json'), 'w', encoding='utf-8')
as user_file:
                     json.dump(users, user_file, default=str)
-            except:
+            except Exception:
                 log.exception('Error extracting %s' % pid)
 
         if options.load:
             try:
                 project = create_project(pid, nbhd)
-            except:
+            except Exception:
                 log.exception('Error creating %s' % pid)
 
 
diff --git a/scripts/wiki-copy.py b/scripts/wiki-copy.py
index 7769357..1e2b4cb 100644
--- a/scripts/wiki-copy.py
+++ b/scripts/wiki-copy.py
@@ -66,7 +66,7 @@ def main():
             else:
                 print("Error posting {0} to {1}: {2} (project may not exist)".format(page_json['title'],
to_url, resp[0]['status']))
                 break
-        except:
+        except Exception:
             print("Error processing " + p)
             raise
 


Mime
View raw message