From 76afc30229812547f0624fc681710a877fe0fde8 Mon Sep 17 00:00:00 2001
From: Jacob Kaplan-Moss <jacob@jacobian.org>
Date: Sun, 14 Feb 2010 20:29:42 +0000
Subject: [PATCH] Fixed a couple Python 2.4 incompatibilities.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12434 bcc190cf-cafb-0310-a4f2-bffc1f526a37
---
 django/utils/feedgenerator.py                       | 8 +++++++-
 tests/regressiontests/test_client_regress/models.py | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index 06008d36e8..856c164d81 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py
@@ -52,10 +52,16 @@ def get_tag_uri(url, date):
     See http://diveintomark.org/archives/2004/05/28/howto-atom-id
     """
     url_split = urlparse.urlparse(url)
+
+    # Python 2.4 didn't have named attributes on split results or the hostname.
+    hostname = getattr(url_split, 'hostname', url_split[1].split(':')[0])
+    path = url_split[2]
+    fragment = url_split[5]
+
     d = ''
     if date is not None:
         d = ',%s' % date.strftime('%Y-%m-%d')
-    return u'tag:%s%s:%s/%s' % (url_split.hostname, d, url_split.path, url_split.fragment)
+    return u'tag:%s%s:%s/%s' % (hostname, d, path, fragment)
 
 class SyndicationFeed(object):
     "Base class for all syndication feeds. Subclasses should provide write()"
diff --git a/tests/regressiontests/test_client_regress/models.py b/tests/regressiontests/test_client_regress/models.py
index f3585268b3..9b40591a73 100644
--- a/tests/regressiontests/test_client_regress/models.py
+++ b/tests/regressiontests/test_client_regress/models.py
@@ -606,7 +606,7 @@ class ContextTests(TestCase):
             response.context['does-not-exist']
             self.fail('Should not be able to retrieve non-existent key')
         except KeyError, e:
-            self.assertEquals(e.message, 'does-not-exist')
+            self.assertEquals(e.args[0], 'does-not-exist')
 
     def test_inherited_context(self):
         "Context variables can be retrieved from a list of contexts"
@@ -621,7 +621,7 @@ class ContextTests(TestCase):
             response.context['does-not-exist']
             self.fail('Should not be able to retrieve non-existent key')
         except KeyError, e:
-            self.assertEquals(e.message, 'does-not-exist')
+            self.assertEquals(e.args[0], 'does-not-exist')
 
 
 class SessionTests(TestCase):