Another gentle ping! :)
Kind regards,
Torbjörn
On 2026-04-14 08:42, Torbjorn SVENSSON wrote:
Gentle ping! :)
Kind regards,
Torbjörn
On 2026-04-07 14:41, Torbjörn SVENSSON wrote:
Ok for trunk and releases/gcc-15?
--
Without this patch, errors like below can be seen in g++.log:
Traceback (most recent call last):
File "/build/gcc_src/gcc/testsuite/g++.dg/modules/test-p1689.py", line 220, in
<module>
is_ok = validate_p1689(actual, expect)
...
File "/build/gcc_src/gcc/testsuite/g++.dg/modules/test-p1689.py", line 149,
in compare_json
actual = set(actual)
TypeError: unhashable type: 'dict'
To avoid hashing dicts, transform the elements to string representation
prior to sorting the array and then transform back to objects after.
gcc/testsuite/ChangeLog:
* g++.dg/modules/test-p1689.py: Make arrays have predictable
order.
Signed-off-by: Torbjörn SVENSSON <[email protected]>
---
gcc/testsuite/g++.dg/modules/test-p1689.py | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/gcc/testsuite/g++.dg/modules/test-p1689.py
b/gcc/testsuite/g++.dg/modules/test-p1689.py
index 2f07cc361aa..b9cb3ebfc32 100644
--- a/gcc/testsuite/g++.dg/modules/test-p1689.py
+++ b/gcc/testsuite/g++.dg/modules/test-p1689.py
@@ -131,6 +131,16 @@ def _inspect_ordering(arr):
return arr, req_ordering
+def _get_predictable_ordered_array(arr):
+ if not arr:
+ return arr
+
+ # Convert to list of string to get predictable order.
+ # Using set() here causes issue with complex arrays
+ arr = [json.dumps(x) for x in arr]
+ arr.sort()
+ return [json.loads(x) for x in arr]
+
def compare_json(path, actual, expect):
actual_type = type(actual)
@@ -146,8 +156,8 @@ def compare_json(path, actual, expect):
elif actual_type == list:
expect, req_ordering = _inspect_ordering(expect)
if not req_ordering:
- actual = set(actual)
- expect = set(expect)
+ actual = _get_predictable_ordered_array(actual)
+ expect = _get_predictable_ordered_array(expect)
is_ok = _compare_array(path, actual, expect)
elif actual_type == str:
is_ok = _compare_string(path, actual, expect)