[python-debian/master] Allow the use of unicode objects in Deb822Dict.__getitem__
John Wright
john.wright at hp.com
Mon Sep 15 23:44:19 UTC 2008
Keys are still stored internally by CaseInsensitiveString as str objects, but
this fixes CaseInsensitiveString's __eq__ method so that it works with unicode
objects as well as str objects.
Eventually, I would like to make CaseInsensitiveString actually subclass
unicode instead of str, but that will involve a few other changes, which I'm
working on in another branch.
---
debian/changelog | 5 ++++-
debian_bundle/deb822.py | 2 +-
tests/test_deb822.py | 4 ++++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index db01935..b913f5f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,7 +11,10 @@ python-debian (0.1.12) UNRELEASED; urgency=low
relative regression test. Thanks to Cameron Dale and Tom Parker.
(Closes: #462859).
- -- John Wright <jsw at debian.org> Sat, 09 Aug 2008 17:15:34 -0600
+ [ John Wright ]
+ * deb822: allow the use of unicode objects in __getitem__
+
+ -- John Wright <jsw at debian.org> Mon, 15 Sep 2008 17:40:44 -0600
python-debian (0.1.11) unstable; urgency=low
diff --git a/debian_bundle/deb822.py b/debian_bundle/deb822.py
index fbc96eb..2e41173 100644
--- a/debian_bundle/deb822.py
+++ b/debian_bundle/deb822.py
@@ -932,7 +932,7 @@ class _CaseInsensitiveString(str):
return self.str_lower_hash
def __eq__(self, other):
- return str.__eq__(self.str_lower, other.lower())
+ return self.str_lower == other.lower()
def lower(self):
return self.str_lower
diff --git a/tests/test_deb822.py b/tests/test_deb822.py
index 04498d4..a567bb7 100755
--- a/tests/test_deb822.py
+++ b/tests/test_deb822.py
@@ -287,6 +287,10 @@ class TestDeb822Dict(unittest.TestCase):
self.assertEqual(d1, d2)
+ def test_unicode_key_access(self):
+ d = self.make_dict()
+ self.assertEqual(1, d[u'testkey'])
+
class TestDeb822(unittest.TestCase):
def assertWellParsed(self, deb822_, dict_):
--
1.5.5.GIT
More information about the pkg-python-debian-commits
mailing list