[python-debian/master] use __new__ to sub-class string: fix deprecation with 2.6
Stefano Zacchiroli
zack at upsilon.cc
Mon Apr 27 08:49:07 UTC 2009
Closes: #524061
---
debian/changelog | 3 +++
debian_bundle/deb822.py | 9 +++++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 5be5b5e..8a60f6e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,9 @@ python-debian (0.1.14) UNRELEASED; urgency=low
add matching build-dep on python-setuptools (Closes: #525694)
* examples/deb822/: add new example render-dctrl, to render packages in
a dctrl-tools pipeline (using Markdown as long description syntax)
+ * deb822: use __new__ to sub-class strings for case-insensitiveness;
+ former approach is deprecated with python 2.6.
+ Thanks to Loïc Minier for the patch. (Closes: #524061)
-- Stefano Zacchiroli <zack at debian.org> Sun, 26 Apr 2009 18:08:50 +0200
diff --git a/debian_bundle/deb822.py b/debian_bundle/deb822.py
index 97aaf20..125f451 100644
--- a/debian_bundle/deb822.py
+++ b/debian_bundle/deb822.py
@@ -1048,10 +1048,11 @@ class _CaseInsensitiveString(str):
"""Case insensitive string.
"""
- def __init__(self, str_):
- str.__init__(self, str_)
- self.str_lower = str_.lower()
- self.str_lower_hash = hash(self.str_lower)
+ def __new__(cls, str_):
+ s = str.__new__(cls, str_)
+ s.str_lower = str_.lower()
+ s.str_lower_hash = hash(s.str_lower)
+ return s
def __hash__(self):
return self.str_lower_hash
--
1.5.6.5
More information about the pkg-python-debian-commits
mailing list