diff --git a/src/linkahead/common/models.py b/src/linkahead/common/models.py index 483c5231d44fe375e0eb1f6448048a11597a4445..9df9788e32df4879ee8fbadf80104c671c9be5f9 100644 --- a/src/linkahead/common/models.py +++ b/src/linkahead/common/models.py @@ -1709,8 +1709,8 @@ def _parse_value(datatype, value): return ret # This is for a special case, where the xml parser could not differentiate - # between single values and lists with one element. As - if hasattr(value, "__len__") and len(value) == 1: + # between single values and lists with one element. + if hasattr(value, "__len__") and not isinstance(value, str) and len(value) == 1: return _parse_value(datatype, value[0]) # deal with references diff --git a/unittests/test_issues.py b/unittests/test_issues.py index 7472f710cea32c1d76f11e52fe7c3c3617804c3c..ba934009156fdb623d811efcf1c871f576d4f2e3 100644 --- a/unittests/test_issues.py +++ b/unittests/test_issues.py @@ -64,3 +64,9 @@ def test_issue_156(): # </ParentList> assert value is project assert parents[0].name == "RTName" + + +def test_parse_datatype(): + """No infinite recursion.""" + from linkahead.common.models import _parse_value + assert 1 == _parse_value("labels0", "1")