Merge pull request #2507 from tausbn/python-fix-infinite-tuple-tostring

Python: Fix divergence in tuple `toString`.
This commit is contained in:
Rasmus Wriedt Larsen
2020-01-27 11:14:44 +01:00
committed by GitHub

View File

@@ -53,7 +53,13 @@ abstract class TupleObjectInternal extends SequenceObjectInternal {
}
private string item(int n) {
result = this.getItem(n).toString()
exists(ObjectInternal item | item = this.getItem(n) |
// To avoid infinite recursion, nested tuples are replaced with the string "...".
if item instanceof TupleObjectInternal then
result = "(...)"
else
result = item.toString()
)
or
n in [0..this.length()-1] and
not exists(this.getItem(n)) and result = "?"