Skip to content

Commit

Permalink
python: Handle empty object set
Browse files Browse the repository at this point in the history
If an objectset had no objects, it would crash when attempt to encode
them.
  • Loading branch information
JPEWdev committed Dec 10, 2024
1 parent 4b30395 commit d10f1e5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/shacl2code/lang/templates/python.j2
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ class SHACLObjectSet(object):
with list_s.write_list_item() as item_s:
o.encode(item_s, state)

else:
elif objects:
objects[0].encode(encoder, state)

def decode(self, decoder):
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/python/context/test-context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ def walk_callback(value, path):
with list_s.write_list_item() as item_s:
o.encode(item_s, state)

else:
elif objects:
objects[0].encode(encoder, state)

def decode(self, decoder):
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/python/nocontext/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ def walk_callback(value, path):
with list_s.write_list_item() as item_s:
o.encode(item_s, state)

else:
elif objects:
objects[0].encode(encoder, state)

def decode(self, decoder):
Expand Down

0 comments on commit d10f1e5

Please sign in to comment.