Skip to content

Commit 529796c

Browse files
committed
Check for type when extracting RDFa content
1 parent 8a795f5 commit 529796c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

extruct/rdfa.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ def extract_items(self, document, base_url=None, expanded=True):
151151
refresh_vocab_cache=False,
152152
check_lite=False)
153153
g = PyRdfa(options, base=base_url).graph_from_DOM(document, graph=Graph(), pgraph=Graph())
154-
jsonld_string = g.serialize(format='json-ld', auto_compact=not expanded).decode('utf-8')
154+
jsonld_string = g.serialize(format='json-ld', auto_compact=not expanded)
155+
156+
# rdflib may return either bytes or strings
157+
if isinstance(jsonld_string, bytes):
158+
jsonld_string = jsonld_string.decode('utf-8')
155159

156160
try:
157161
# hack to fix the ordering of multi-value properties (see issue 116)

0 commit comments

Comments
 (0)