Skip to content

Commit 14071b0

Browse files
authored
Fix failing webtest (#3194)
* test: fix failing webtest Fixes #3192 * Revert "remove old hacks against 2to3 (#3076)" (#3195) This reverts commit b74c657.
1 parent 0c16362 commit 14071b0

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

rdflib/plugins/parsers/rdfxml.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ def document_element_start(
298298
self, name: Tuple[str, str], qname, attrs: AttributesImpl
299299
) -> None:
300300
if name[0] and URIRef("".join(name)) == RDFVOC.RDF:
301-
next = self.next
301+
# Cheap hack so 2to3 doesn't turn it into __next__
302+
next = getattr(self, "next")
302303
next.start = self.node_element_start
303304
next.end = self.node_element_end
304305
else:
@@ -315,7 +316,8 @@ def node_element_start(
315316
current = self.current
316317
absolutize = self.absolutize
317318

318-
next = self.next
319+
# Cheap hack so 2to3 doesn't turn it into __next__
320+
next = getattr(self, "next")
319321
next.start = self.property_element_start
320322
next.end = self.property_element_end
321323

@@ -408,7 +410,8 @@ def property_element_start(
408410
current = self.current
409411
absolutize = self.absolutize
410412

411-
next = self.next
413+
# Cheap hack so 2to3 doesn't turn it into __next__
414+
next = getattr(self, "next")
412415
object: Optional[_ObjectType] = None
413416
current.data = None
414417
current.list = None

rdflib/plugins/stores/berkeleydb.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ def remove( # type: ignore[override]
428428
cursor = index.cursor(txn=txn)
429429
try:
430430
cursor.set_range(key)
431-
current = cursor.next
431+
# Hack to stop 2to3 converting this to next(cursor)
432+
current = getattr(cursor, "next")()
432433
except db.DBNotFoundError:
433434
current = None
434435
cursor.close()
@@ -505,7 +506,8 @@ def triples(
505506
cursor = index.cursor(txn=txn)
506507
try:
507508
cursor.set_range(key)
508-
current = cursor.next
509+
# Cheap hack so 2to3 doesn't convert to next(cursor)
510+
current = getattr(cursor, "next")()
509511
except db.DBNotFoundError:
510512
current = None
511513
cursor.close()
@@ -537,7 +539,8 @@ def __len__(self, context: Optional[_ContextType] = None) -> int:
537539
key, value = current
538540
if key.startswith(prefix):
539541
count += 1
540-
current = cursor.next
542+
# Hack to stop 2to3 converting this to next(cursor)
543+
current = getattr(cursor, "next")()
541544
else:
542545
break
543546
cursor.close()
@@ -590,7 +593,8 @@ def namespaces(self) -> Generator[Tuple[str, URIRef], None, None]:
590593
while current:
591594
prefix, namespace = current
592595
results.append((prefix.decode("utf-8"), namespace.decode("utf-8")))
593-
current = cursor.next
596+
# Hack to stop 2to3 converting this to next(cursor)
597+
current = getattr(cursor, "next")()
594598
cursor.close()
595599
for prefix, namespace in results:
596600
yield prefix, URIRef(namespace)
@@ -633,7 +637,8 @@ def contexts(
633637
cursor = index.cursor()
634638
try:
635639
cursor.set_range(key)
636-
current = cursor.next
640+
# Hack to stop 2to3 converting this to next(cursor)
641+
current = getattr(cursor, "next")()
637642
except db.DBNotFoundError:
638643
current = None
639644
cursor.close()

test/test_graph/test_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def test_guess_format_for_parse_http_text_plain():
399399
assert len(graph) > 0
400400

401401
# A url that returns content-type text/html.
402-
url = "https://github.com/RDFLib/rdflib/issues/2734"
402+
url = "https://www.w3.org/TR/REC-rdf-syntax/"
403403
with pytest.raises(PluginException):
404404
graph = Graph().parse(url)
405405

0 commit comments

Comments
 (0)