Skip to content

Commit

Permalink
added test and fixed #312
Browse files Browse the repository at this point in the history
  • Loading branch information
gromgull committed Dec 30, 2013
1 parent 6b4622d commit 1cfcfda
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rdflib/plugins/parsers/notation3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,8 +1165,11 @@ def uri_ref2(self, argstr, i, res):
if pfx == "_": # Magic prefix 2001/05/30, can be changed
res.append(self.anonymousNode(ln))
return j
self.BadSyntax(argstr, i,
"Prefix \"%s:\" not bound" % (pfx))
if not self.turtle and pfx == "":
ns = join(self._baseURI or "", "#")
else:
self.BadSyntax(argstr, i,
"Prefix \"%s:\" not bound" % (pfx))
symb = self._store.newSymbol(ns + ln)
if symb in self._variables:
res.append(self._variables[symb])
Expand Down
11 changes: 11 additions & 0 deletions test/test_n3.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,16 @@ def testSingleQuotedLiterals(self):
for _, _, o in g:
self.assertEqual(o, Literal('o'))

def testEmptyPrefix(self):

# this is issue https://github.com/RDFLib/rdflib/issues/312
g1 = Graph()
g1.parse(data = ":a :b :c .", format='n3')

g2 = Graph()
g2.parse(data = "@prefix : <#> . :a :b :c .", format='n3')

assert set(g1) == set(g2), 'Document with declared empty prefix must match default #'

if __name__ == '__main__':
unittest.main()

0 comments on commit 1cfcfda

Please sign in to comment.