[PATCH] deb822: Make Deb822Dict unhashable.
John Wright
jsw at debian.org
Sun Jul 3 10:07:18 UTC 2011
Mutable containers should generally not be hashable. Strangely (to me,
at laest), DictMixin inherits the default __hash__ implementation, which
makes Python complain with -3. This patch explicitly sets __hash__ to
None.
This is one (very small) step toward Python 3 compatibility.
---
lib/debian/deb822.py | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/lib/debian/deb822.py b/lib/debian/deb822.py
index 47c921d..11429cc 100644
--- a/lib/debian/deb822.py
+++ b/lib/debian/deb822.py
@@ -33,7 +33,6 @@ except (ImportError, AttributeError):
_have_apt_pkg = False
import chardet
-import new
import re
import string
import sys
@@ -130,6 +129,9 @@ class Deb822Dict(object, UserDict.DictMixin):
in the _parsed dictionary are exposed.
"""
+ # Mutable containers should not be hashable.
+ __hash__ = None
+
# See the end of the file for the definition of _strI
def __init__(self, _dict=None, _parsed=None, _fields=None,
@@ -786,10 +788,12 @@ class PkgRelation(object):
def pp_atomic_dep(dep):
s = dep['name']
- if dep.has_key('version') and dep['version'] is not None:
- s += ' (%s %s)' % dep['version']
- if dep.has_key('arch') and dep['arch'] is not None:
- s += ' [%s]' % string.join(map(pp_arch, dep['arch']))
+ version = dep.get('version')
+ arch = dep.get('arch')
+ if version is not None:
+ s += ' (%s %s)' % version
+ if arch is not None:
+ s += ' [%s]' % string.join(map(pp_arch, arch))
return s
pp_or_dep = lambda deps: string.join(map(pp_atomic_dep, deps), ' | ')
--
1.7.4.4
More information about the pkg-python-debian-maint
mailing list