[saem-devel] [PATCH 1 of 1 skos] [rdf] Don't propagate exception if language isn't accepted by rdflib

Sylvain Thenault sylvain.thenault at logilab.fr
Thu Feb 23 09:45:53 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1485776389 -3600
#      Mon Jan 30 12:39:49 2017 +0100
# Node ID dabbe335e45634a7d8d1d129fa02bb49ab3f28c3
# Parent  68ddcfc7441e9d3d03df516764e1a6c8ce127240
[rdf] Don't propagate exception if language isn't accepted by rdflib

diff --git a/rdfio.py b/rdfio.py
--- a/rdfio.py
+++ b/rdfio.py
@@ -256,11 +256,14 @@ class AbstractRDFGraph(object):
         """
         assert isinstance(subj, self.uri)
         assert isinstance(predicate, self.uri)
         if not isinstance(obj, self.uri):
             if isinstance(obj, unicode_with_language):
-                obj = self._literal(text_type(obj), lang=obj.lang)
+                try:
+                    obj = self._literal(text_type(obj), lang=obj.lang)
+                except Exception:
+                    obj = self._literal(obj)
             else:
                 obj = self._literal(obj)
         self._add(subj, predicate, obj)
 
     def _add(self, subj, predicate, obj):


More information about the saem-devel mailing list