Skip to content

Commit

Permalink
Fix issue #16: Remove code that breaks conversion to Python of prolog…
Browse files Browse the repository at this point in the history
… constructs on the form ",(..., [])".

Also add test for this.
  • Loading branch information
VorpalBlade committed Apr 11, 2022
1 parent 5e12d51 commit 224f47f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions problog/pypl.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ def pl2py(d):
while isinstance(tail, Term) and tail.arity == 2 and tail.functor == ",":
elements.append(pl2py(tail.args[0]))
tail = tail.args[1]
if str(tail) != "[]":
elements.append(pl2py(tail))
elements.append(pl2py(tail))
return tuple(elements)
elif d.functor == "[]":
return []
Expand Down
5 changes: 5 additions & 0 deletions problog/test/test_pypl.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ def test_unsupported_types(self):
test_dict = {"a": 1}
with self.assertRaises(ValueError):
py2pl(test_dict)

def test_list_at_end_of_comma_double_conversion(self):
test_value = (1, [])
res_value = pl2py(py2pl(test_value))
self.assertEqual(test_value, res_value)

0 comments on commit 224f47f

Please sign in to comment.