Skip to content

Commit 3a3b858

Browse files
committed
Revert "remove old hacks against 2to3 (#3076)"
This reverts commit b74c657.
1 parent 4281096 commit 3a3b858

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
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: _ObjectType | None = 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
@@ -427,7 +427,8 @@ def remove( # type: ignore[override]
427427
cursor = index.cursor(txn=txn)
428428
try:
429429
cursor.set_range(key)
430-
current = cursor.next
430+
# Hack to stop 2to3 converting this to next(cursor)
431+
current = getattr(cursor, "next")()
431432
except db.DBNotFoundError:
432433
current = None
433434
cursor.close()
@@ -504,7 +505,8 @@ def triples(
504505
cursor = index.cursor(txn=txn)
505506
try:
506507
cursor.set_range(key)
507-
current = cursor.next
508+
# Cheap hack so 2to3 doesn't convert to next(cursor)
509+
current = getattr(cursor, "next")()
508510
except db.DBNotFoundError:
509511
current = None
510512
cursor.close()
@@ -536,7 +538,8 @@ def __len__(self, context: _ContextType | None = None) -> int:
536538
key, value = current
537539
if key.startswith(prefix):
538540
count += 1
539-
current = cursor.next
541+
# Hack to stop 2to3 converting this to next(cursor)
542+
current = getattr(cursor, "next")()
540543
else:
541544
break
542545
cursor.close()
@@ -589,7 +592,8 @@ def namespaces(self) -> Generator[tuple[str, URIRef], None, None]:
589592
while current:
590593
prefix, namespace = current
591594
results.append((prefix.decode("utf-8"), namespace.decode("utf-8")))
592-
current = cursor.next
595+
# Hack to stop 2to3 converting this to next(cursor)
596+
current = getattr(cursor, "next")()
593597
cursor.close()
594598
for prefix, namespace in results:
595599
yield prefix, URIRef(namespace)
@@ -628,7 +632,8 @@ def contexts(
628632
cursor = index.cursor()
629633
try:
630634
cursor.set_range(key)
631-
current = cursor.next
635+
# Hack to stop 2to3 converting this to next(cursor)
636+
current = getattr(cursor, "next")()
632637
except db.DBNotFoundError:
633638
current = None
634639
cursor.close()

0 commit comments

Comments
 (0)