Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rdflib/plugins/stores/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def contexts(
self, triple: Optional[_TripleType] = None
) -> Generator[_ContextType, None, None]:
if triple is None or triple == (None, None, None):
return (context for context in self.__all_contexts)
return (context for context in list(self.__all_contexts))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix.


subj, pred, obj = triple
try:
Expand Down
17 changes: 17 additions & 0 deletions test/test_store/test_store_memorystore.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,20 @@ def test_memory_store(get_graph):
g.remove(triple1)
assert len(g) == 1
assert len(g.serialize()) > 0


def test_sparql_bindings_creating_new_graph():
# Test for https://github.com/RDFLib/rdflib/issues/3102
dataset = rdflib.Dataset()
# Create a graph
dataset.graph(identifier="urn:example:graph")
sparql_query = """
SELECT *
WHERE {
GRAPH ?g_1 { }
GRAPH ?g_2 { }
}"""

# Ensure it doesn't raise RuntimeError: Set changed size during iteration
results = dataset.query(sparql_query)
assert len(results) == 1
Loading