From 46e4ba258fd2e74384a6a43b9edbe55754518bc2 Mon Sep 17 00:00:00 2001 From: Craig Blaszczyk Date: Wed, 4 Jan 2012 18:05:12 +0000 Subject: [PATCH] #75 remove except statements which are overly broad in the exception they catch --- djangorestframework/renderers.py | 4 ++-- djangorestframework/utils/__init__.py | 2 +- djangorestframework/utils/breadcrumbs.py | 2 +- djangorestframework/utils/mediatypes.py | 2 +- examples/pygments_api/tests.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/djangorestframework/renderers.py b/djangorestframework/renderers.py index 0c80f07e8..240de69ed 100644 --- a/djangorestframework/renderers.py +++ b/djangorestframework/renderers.py @@ -246,14 +246,14 @@ class DocumentingTemplateRenderer(BaseRenderer): form_instance = view.get_bound_form(view.response.cleaned_content, method=method) if form_instance and not form_instance.is_valid(): form_instance = None - except: + except Exception: form_instance = None # If we still don't have a form instance then try to get an unbound form if not form_instance: try: form_instance = view.get_bound_form(method=method) - except: + except Exception: pass # If we still don't have a form instance then try to get an unbound form which can tunnel arbitrary content types diff --git a/djangorestframework/utils/__init__.py b/djangorestframework/utils/__init__.py index 305311f44..2b4fd10e9 100644 --- a/djangorestframework/utils/__init__.py +++ b/djangorestframework/utils/__init__.py @@ -43,7 +43,7 @@ def url_resolves(url): """ try: resolve(url) - except: + except Exception: return False return True diff --git a/djangorestframework/utils/breadcrumbs.py b/djangorestframework/utils/breadcrumbs.py index 6cf978edb..fd966282f 100644 --- a/djangorestframework/utils/breadcrumbs.py +++ b/djangorestframework/utils/breadcrumbs.py @@ -11,7 +11,7 @@ def get_breadcrumbs(url): try: (view, unused_args, unused_kwargs) = resolve(url) - except: + except Exception: pass else: # Check if this is a REST framework view, and if so add it to the breadcrumbs diff --git a/djangorestframework/utils/mediatypes.py b/djangorestframework/utils/mediatypes.py index 3c0eefc4e..c0071f011 100644 --- a/djangorestframework/utils/mediatypes.py +++ b/djangorestframework/utils/mediatypes.py @@ -109,7 +109,7 @@ class _MediaType(object): # """ # try: # return Decimal(self.params.get('q', '1.0')) - # except: + # except Exception: # return Decimal(0) #def score(self): diff --git a/examples/pygments_api/tests.py b/examples/pygments_api/tests.py index 98139ce25..247266476 100644 --- a/examples/pygments_api/tests.py +++ b/examples/pygments_api/tests.py @@ -18,7 +18,7 @@ class TestPygmentsExample(TestCase): def tearDown(self): try: shutil.rmtree(self.temp_dir) - except: + except Exception: pass def test_get_to_root(self):