Removed some Python < 2.6 compatibility code. Refs #17965.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17830 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Aymeric Augustin 2012-03-30 09:20:04 +00:00
parent eb163f37cb
commit 4fe87c370d
5 changed files with 9 additions and 38 deletions

View File

@ -1,5 +1,3 @@
import sys
from django.test import LiveServerTestCase
from django.utils.importlib import import_module
from django.utils.unittest import SkipTest
@ -10,8 +8,6 @@ class AdminSeleniumWebDriverTestCase(LiveServerTestCase):
@classmethod
def setUpClass(cls):
if sys.version_info < (2, 6):
raise SkipTest('Selenium Webdriver does not support Python < 2.6.')
try:
# Import and start the WebDriver class.
module, attr = cls.webdriver_class.rsplit('.', 1)

View File

@ -1,4 +1,3 @@
import platform
import re
import urllib
import urllib2
@ -123,10 +122,7 @@ class URLValidator(RegexValidator):
else:
handlers.append(urllib2.HTTPSHandler())
map(opener.add_handler, handlers)
if platform.python_version_tuple() >= (2, 6):
opener.open(req, timeout=10)
else:
opener.open(req)
opener.open(req, timeout=10)
except ValueError:
raise ValidationError(_(u'Enter a valid URL.'), code='invalid')
except: # urllib2.URLError, httplib.InvalidURL, etc.

View File

@ -1035,12 +1035,8 @@ class LiveServerThread(threading.Thread):
self.httpd = StoppableWSGIServer(
(self.host, port), QuietWSGIRequestHandler)
except WSGIServerException, e:
if sys.version_info < (2, 6):
error_code = e.args[0].args[0]
else:
error_code = e.args[0].errno
if (index + 1 < len(self.possible_ports) and
error_code == errno.EADDRINUSE):
e.args[0].errno == errno.EADDRINUSE):
# This port is already in use, so we go on and try with
# the next one in the list.
continue

View File

@ -207,20 +207,9 @@ def quote_etag(etag):
"""
return '"%s"' % etag.replace('\\', '\\\\').replace('"', '\\"')
if sys.version_info >= (2, 6):
def same_origin(url1, url2):
"""
Checks if two URLs are 'same-origin'
"""
p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2)
return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port)
else:
# Python 2.5 compatibility. This actually works for Python 2.6 and above,
# but the above definition is much more obviously correct and so is
# preferred going forward.
def same_origin(url1, url2):
"""
Checks if two URLs are 'same-origin'
"""
p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2)
return p1[0:2] == p2[0:2]
def same_origin(url1, url2):
"""
Checks if two URLs are 'same-origin'
"""
p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2)
return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port)

View File

@ -2,7 +2,6 @@
import errno
import os
import shutil
import sys
import tempfile
import time
from datetime import datetime, timedelta
@ -470,12 +469,7 @@ class FileStoragePathParsing(unittest.TestCase):
self.storage.save('dotted.path/.test', ContentFile("2"))
self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/.test')))
# Before 2.6, a leading dot was treated as an extension, and so
# underscore gets added to beginning instead of end.
if sys.version_info < (2, 6):
self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/_1.test')))
else:
self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/.test_1')))
self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/.test_1')))
class DimensionClosingBug(unittest.TestCase):
"""