Skip to content

Commit b74c657

Browse files
remove old hacks against 2to3 (#3076)
This reverts e2fb491 Co-authored-by: Nicholas Car <[email protected]>
1 parent 69b7d6c commit b74c657

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

rdflib/plugins/parsers/rdfxml.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ 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-
# Cheap hack so 2to3 doesn't turn it into __next__
302-
next = getattr(self, "next")
301+
next = self.next
303302
next.start = self.node_element_start
304303
next.end = self.node_element_end
305304
else:
@@ -316,8 +315,7 @@ def node_element_start(
316315
current = self.current
317316
absolutize = self.absolutize
318317

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

@@ -410,8 +408,7 @@ def property_element_start(
410408
current = self.current
411409
absolutize = self.absolutize
412410

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

rdflib/plugins/stores/berkeleydb.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,7 @@ def remove( # type: ignore[override]
428428
cursor = index.cursor(txn=txn)
429429
try:
430430
cursor.set_range(key)
431-
# Hack to stop 2to3 converting this to next(cursor)
432-
current = getattr(cursor, "next")()
431+
current = cursor.next
433432
except db.DBNotFoundError:
434433
current = None
435434
cursor.close()
@@ -506,8 +505,7 @@ def triples(
506505
cursor = index.cursor(txn=txn)
507506
try:
508507
cursor.set_range(key)
509-
# Cheap hack so 2to3 doesn't convert to next(cursor)
510-
current = getattr(cursor, "next")()
508+
current = cursor.next
511509
except db.DBNotFoundError:
512510
current = None
513511
cursor.close()
@@ -539,8 +537,7 @@ def __len__(self, context: Optional[_ContextType] = None) -> int:
539537
key, value = current
540538
if key.startswith(prefix):
541539
count += 1
542-
# Hack to stop 2to3 converting this to next(cursor)
543-
current = getattr(cursor, "next")()
540+
current = cursor.next
544541
else:
545542
break
546543
cursor.close()
@@ -593,8 +590,7 @@ def namespaces(self) -> Generator[Tuple[str, URIRef], None, None]:
593590
while current:
594591
prefix, namespace = current
595592
results.append((prefix.decode("utf-8"), namespace.decode("utf-8")))
596-
# Hack to stop 2to3 converting this to next(cursor)
597-
current = getattr(cursor, "next")()
593+
current = cursor.next
598594
cursor.close()
599595
for prefix, namespace in results:
600596
yield prefix, URIRef(namespace)
@@ -637,8 +633,7 @@ def contexts(
637633
cursor = index.cursor()
638634
try:
639635
cursor.set_range(key)
640-
# Hack to stop 2to3 converting this to next(cursor)
641-
current = getattr(cursor, "next")()
636+
current = cursor.next
642637
except db.DBNotFoundError:
643638
current = None
644639
cursor.close()

0 commit comments

Comments
 (0)