From 20b3d1c1cb905861f07a2df65ceeb6567edc07c6 Mon Sep 17 00:00:00 2001 From: Arnav Kumar Date: Fri, 29 May 2020 21:32:48 +0530 Subject: [PATCH] Fixed the return type of parse function of ConjunctiveGraph (Issue #939) --- rdflib/graph.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/rdflib/graph.py b/rdflib/graph.py index c541f1d5b..d36b2d4cd 100644 --- a/rdflib/graph.py +++ b/rdflib/graph.py @@ -1600,15 +1600,25 @@ def parse( data=data, format=format, ) + g_id = publicID and publicID or source.getPublicId() if not isinstance(g_id, Node): g_id = URIRef(g_id) - - context = Graph(store=self.store, identifier=g_id) - context.remove((None, None, None)) # hmm ? - context.parse(source, publicID=publicID, format=format, **args) - return context + + if format is None: + format = source.content_type + if format is None: + # raise Exception("Could not determine format for %r. You can" + \ + # "expicitly specify one with the format argument." % source) + format = "application/rdf+xml" + parser = plugin.get(format, Parser)() + try: + parser.parse(source, self, **args) + finally: + if source.auto_close: + source.close() + return self def __reduce__(self): return ConjunctiveGraph, (self.store, self.identifier)