summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoern Hees <dev@joernhees.de>2015-07-21 16:42:04 +0200
committerJoern Hees <dev@joernhees.de>2015-07-21 16:42:43 +0200
commitec93eeddb10b960a943db4a7f2ab664a8f88e049 (patch)
treea41a9b10d4af437e719bedcf1e830032533ee5ab
parent4e257e45a5bc55e1d3c4be15ed6d448a5e68b04e (diff)
downloadrdflib-ec93eeddb10b960a943db4a7f2ab664a8f88e049.tar.gz
make Identifier.__hash__ stable wrt. multi processes, fixes #500
-rw-r--r--rdflib/term.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/rdflib/term.py b/rdflib/term.py
index 91cc06ea..561c3e60 100644
--- a/rdflib/term.py
+++ b/rdflib/term.py
@@ -183,7 +183,9 @@ class Identifier(Node, unicode): # allow Identifiers to be Nodes in the Graph
return self == other
def __hash__(self):
- return hash(type(self)) ^ hash(unicode(self))
+ t = type(self)
+ fqn = t.__module__ + '.' + t.__name__
+ return hash(fqn) ^ hash(unicode(self))
class URIRef(Identifier):
@@ -930,8 +932,12 @@ class Literal(Identifier):
-- 6.5.1 Literal Equality (RDF: Concepts and Abstract Syntax)
"""
-
- return unicode.__hash__(self) ^ hash(self.language.lower() if self.language else None) ^ hash(self.datatype)
+ res = super(Literal, self).__hash__()
+ if self.language:
+ res ^= hash(self.language.lower())
+ if self.datatype:
+ res ^= hash(self.datatype)
+ return res
@py3compat.format_doctest_out
def __eq__(self, other):