mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Kill some more dead code.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16795 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -51,7 +51,7 @@ class URLValidator(RegexValidator):
|
||||
r'(?::\d+)?' # optional port
|
||||
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
|
||||
|
||||
def __init__(self, verify_exists=False,
|
||||
def __init__(self, verify_exists=False,
|
||||
validator_user_agent=URL_VALIDATOR_USER_AGENT):
|
||||
super(URLValidator, self).__init__()
|
||||
self.verify_exists = verify_exists
|
||||
@@ -99,7 +99,7 @@ class URLValidator(RegexValidator):
|
||||
req.get_method = lambda: 'HEAD'
|
||||
#Create an opener that does not support local file access
|
||||
opener = urllib2.OpenerDirector()
|
||||
|
||||
|
||||
#Don't follow redirects, but don't treat them as errors either
|
||||
error_nop = lambda *args, **kwargs: True
|
||||
http_error_processor = urllib2.HTTPErrorProcessor()
|
||||
@@ -114,10 +114,11 @@ class URLValidator(RegexValidator):
|
||||
http_error_processor]
|
||||
try:
|
||||
import ssl
|
||||
handlers.append(urllib2.HTTPSHandler())
|
||||
except:
|
||||
#Python isn't compiled with SSL support
|
||||
except ImportError:
|
||||
# Python isn't compiled with SSL support
|
||||
pass
|
||||
else:
|
||||
handlers.append(urllib2.HTTPSHandler())
|
||||
map(opener.add_handler, handlers)
|
||||
opener.http_error_301 = lambda: True
|
||||
if platform.python_version_tuple() >= (2, 6):
|
||||
@@ -133,7 +134,7 @@ class URLValidator(RegexValidator):
|
||||
def validate_integer(value):
|
||||
try:
|
||||
int(value)
|
||||
except (ValueError, TypeError), e:
|
||||
except (ValueError, TypeError):
|
||||
raise ValidationError('')
|
||||
|
||||
class EmailValidator(RegexValidator):
|
||||
@@ -145,7 +146,6 @@ class EmailValidator(RegexValidator):
|
||||
# Trivial case failed. Try for possible IDN domain-part
|
||||
if value and u'@' in value:
|
||||
parts = value.split(u'@')
|
||||
domain_part = parts[-1]
|
||||
try:
|
||||
parts[-1] = parts[-1].encode('idna')
|
||||
except UnicodeError:
|
||||
|
||||
Reference in New Issue
Block a user