Commit 4fe87c37 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

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
parent eb163f37
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
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)
+1 −5
Original line number Diff line number Diff line
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)
            except ValueError:
                raise ValidationError(_(u'Enter a valid URL.'), code='invalid')
            except: # urllib2.URLError, httplib.InvalidURL, etc.
+1 −5
Original line number Diff line number Diff line
@@ -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
+6 −17
Original line number Diff line number Diff line
@@ -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]
+1 −7
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
import errno
import os
import shutil
import sys
import tempfile
import time
from datetime import datetime, timedelta
@@ -470,11 +469,6 @@ 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')))

class DimensionClosingBug(unittest.TestCase):