Skip to content

Commit 13475e0

Browse files
authored
gh-128889: Zero out memory ctypes for generated struct layout tests (GH-128944)
1 parent 4b37a6b commit 13475e0

File tree

2 files changed

+147
-74
lines changed

2 files changed

+147
-74
lines changed

Lib/test/test_ctypes/test_generated_structs.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def test_generated_data(self):
443443
- None
444444
- reason to skip the test (str)
445445
446-
This does depend on the C compiler keeping padding bits zero.
446+
This does depend on the C compiler keeping padding bits unchanged.
447447
Common compilers seem to do so.
448448
"""
449449
for name, cls in TESTCASES.items():
@@ -696,7 +696,8 @@ def output(string):
696696
output(' ' + line)
697697
typename = f'{struct_or_union(cls)} {name}'
698698
output(f"""
699-
{typename} value = {{0}};
699+
{typename} value;
700+
memset(&value, 0, sizeof(value));
700701
APPEND(PyUnicode_FromString({c_str_repr(name)}));
701702
APPEND(PyLong_FromLong(sizeof({typename})));
702703
APPEND(PyLong_FromLong(_Alignof({typename})));

0 commit comments

Comments
 (0)