Commit 335a9f9c authored by Alex Gaynor's avatar Alex Gaynor
Browse files

Removed many uses of bare "except:", which were either going to a) silence...

Removed many uses of bare "except:", which were either going to a) silence real issues, or b) were impossible to hit.
parent 257c4011
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ HR-specific Form helpers
"""
from __future__ import absolute_import, unicode_literals

import datetime
import re

from django.contrib.localflavor.hr.hr_choices import (
@@ -91,10 +92,9 @@ class HRJMBGField(Field):
        dd = int(matches.group('dd'))
        mm = int(matches.group('mm'))
        yyy = int(matches.group('yyy'))
        import datetime
        try:
            datetime.date(yyy, mm, dd)
        except:
        except ValueError:
            raise ValidationError(self.error_messages['date'])

        # Validate checksum.
+11 −11
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ Romanian specific form helpers.
"""
from __future__ import absolute_import, unicode_literals

import datetime

from django.contrib.localflavor.ro.ro_counties import COUNTIES_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError, Field, RegexField, Select
@@ -69,10 +71,9 @@ class ROCNPField(RegexField):
        if value in EMPTY_VALUES:
            return ''
        # check birthdate digits
        import datetime
        try:
            datetime.date(int(value[1:3]), int(value[3:5]), int(value[5:7]))
        except:
        except ValueError:
            raise ValidationError(self.error_messages['invalid'])
        # checksum
        key = '279146358279'
@@ -202,4 +203,3 @@ class ROPostalCodeField(RegexField):
    def __init__(self, max_length=6, min_length=6, *args, **kwargs):
        super(ROPostalCodeField, self).__init__(r'^[0-9][0-8][0-9]{4}$',
                max_length, min_length, *args, **kwargs)
+1 −1
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ class CacheClass(BaseMemcachedCache):
        )
        try:
            import memcache
        except:
        except ImportError:
            raise InvalidCacheBackendError(
                "Memcached cache backend requires either the 'memcache' or 'cmemcache' library"
                )
+1 −4
Original line number Diff line number Diff line
@@ -412,7 +412,4 @@ def _sqlite_format_dtdelta(dt, conn, days, secs, usecs):
    return str(dt)

def _sqlite_regexp(re_pattern, re_string):
    try:
    return bool(re.search(re_pattern, re_string))
    except:
        return False
+2 −3
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ class MultiPartParser(object):
        if not boundary or not cgi.valid_boundary(boundary):
            raise MultiPartParserError('Invalid boundary in multipart: %s' % boundary)


        # Content-Length should contain the length of the body we are about
        # to receive.
        try:
Loading