Don't crash on printing nested types
When adding an Array or Dictionary to itself operator String() got in an
infinite loop. This commit adds a stack to operator String() (Through
the use of a new 'stringify method'). This stack keeps track of all
unique Arrays and Dictionaries it has seen. When a duplicate is found
only a static string is printed '[...]' or '{...}'.
This mirror Python's behavior in a similar case.
This commit is contained in:
@ -274,6 +274,10 @@ public:
|
||||
inline bool empty() const { return list.empty(); }
|
||||
inline int size() const { return list.size(); }
|
||||
|
||||
const void *id() const {
|
||||
return list.id();
|
||||
}
|
||||
|
||||
void clear() {
|
||||
map.clear();
|
||||
list.clear();
|
||||
|
||||
Reference in New Issue
Block a user