Skip to content

Commit 427de9d

Browse files
remove old hacks against 2to3 (#3095)
* remove old hacks against 2to3 This reverts e2fb491 * fix .readthedocs.yaml * try fix RTD config --------- Co-authored-by: Nicholas Car <[email protected]> Co-authored-by: Nicholas Car <[email protected]>
1 parent 6f156fc commit 427de9d

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: _ObjectType | None = 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
@@ -429,8 +429,7 @@ def remove( # type: ignore[override]
429429
cursor = index.cursor(txn=txn)
430430
try:
431431
cursor.set_range(key)
432-
# Hack to stop 2to3 converting this to next(cursor)
433-
current = getattr(cursor, "next")()
432+
current = cursor.next
434433
except db.DBNotFoundError:
435434
current = None
436435
cursor.close()
@@ -507,8 +506,7 @@ def triples(
507506
cursor = index.cursor(txn=txn)
508507
try:
509508
cursor.set_range(key)
510-
# Cheap hack so 2to3 doesn't convert to next(cursor)
511-
current = getattr(cursor, "next")()
509+
current = cursor.next
512510
except db.DBNotFoundError:
513511
current = None
514512
cursor.close()
@@ -540,8 +538,7 @@ def __len__(self, context: _ContextType | None = None) -> int:
540538
key, value = current
541539
if key.startswith(prefix):
542540
count += 1
543-
# Hack to stop 2to3 converting this to next(cursor)
544-
current = getattr(cursor, "next")()
541+
current = cursor.next
545542
else:
546543
break
547544
cursor.close()
@@ -594,8 +591,7 @@ def namespaces(self) -> Generator[tuple[str, URIRef], None, None]:
594591
while current:
595592
prefix, namespace = current
596593
results.append((prefix.decode("utf-8"), namespace.decode("utf-8")))
597-
# Hack to stop 2to3 converting this to next(cursor)
598-
current = getattr(cursor, "next")()
594+
current = cursor.next
599595
cursor.close()
600596
for prefix, namespace in results:
601597
yield prefix, URIRef(namespace)
@@ -634,8 +630,7 @@ def contexts(
634630
cursor = index.cursor()
635631
try:
636632
cursor.set_range(key)
637-
# Hack to stop 2to3 converting this to next(cursor)
638-
current = getattr(cursor, "next")()
633+
current = cursor.next
639634
except db.DBNotFoundError:
640635
current = None
641636
cursor.close()

0 commit comments

Comments
 (0)