Python: Fix divergence in tuple `toString`. · github/codeql@3cebffe · GitHub
Skip to content

Commit 3cebffe

Browse files
committed
Python: Fix divergence in tuple toString.
Our definition of `toString` for the internal tuple objects we create during the points-to analysis may have been a _tad_ too ambitious. In particular, it can easily lead to non-termination, e.g. using the following piece of code: ```python x = () while True: x = (x, x) ``` This commit cuts off the infinite recursion by replacing _nested_ tuples with the string "...". In particular this means even non-recursive tuples will be cut off at that point, so that the following tuples ```python (1, "2") ((3, 4), [5, 6]) (1, 2, 3, 4, 5) ``` Get the following string representations. ``` "(int 1, '2', )" "(..., List, )" "(int 1, int 2, int 3, 2 more...)" ```
1 parent 3049bf2 commit 3cebffe

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎python/ql/src/semmle/python/objects/Sequences.qll‎

Lines changed: 7 additions & 1 deletion

0 commit comments

Comments
 (0)