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

View File

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

View File

@ -1035,12 +1035,8 @@ class LiveServerThread(threading.Thread):
self.httpd = StoppableWSGIServer( self.httpd = StoppableWSGIServer(
(self.host, port), QuietWSGIRequestHandler) (self.host, port), QuietWSGIRequestHandler)
except WSGIServerException, e: 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 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 # This port is already in use, so we go on and try with
# the next one in the list. # the next one in the list.
continue continue

View File

@ -207,20 +207,9 @@ def quote_etag(etag):
""" """
return '"%s"' % etag.replace('\\', '\\\\').replace('"', '\\"') return '"%s"' % etag.replace('\\', '\\\\').replace('"', '\\"')
if sys.version_info >= (2, 6): def same_origin(url1, url2):
def same_origin(url1, url2): """
""" Checks if two URLs are 'same-origin'
Checks if two URLs are 'same-origin' """
""" p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2)
p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2) return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port)
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]

View File

@ -2,7 +2,6 @@
import errno import errno
import os import os
import shutil import shutil
import sys
import tempfile import tempfile
import time import time
from datetime import datetime, timedelta from datetime import datetime, timedelta
@ -470,12 +469,7 @@ class FileStoragePathParsing(unittest.TestCase):
self.storage.save('dotted.path/.test', ContentFile("2")) self.storage.save('dotted.path/.test', ContentFile("2"))
self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/.test'))) 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 self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/.test_1')))
# 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')))
class DimensionClosingBug(unittest.TestCase): class DimensionClosingBug(unittest.TestCase):
""" """