Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/test/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ def __bool__(self):

for c in [b'\x01', b'\x7f', b'\xff', b'\x0f', b'\xf0']:
self.assertTrue(struct.unpack('>?', c)[0])
self.assertTrue(struct.unpack('<?', c)[0])
self.assertTrue(struct.unpack('=?', c)[0])
self.assertTrue(struct.unpack('@?', c)[0])

def test_count_overflow(self):
hugecount = '{}b'.format(sys.maxsize+1)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't copy arbitrary values to :c:expr:`_Bool` in the :mod:`struct` module.
5 changes: 2 additions & 3 deletions Modules/_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,8 @@
static PyObject *
nu_bool(_structmodulestate *state, const char *p, const formatdef *f)
{
_Bool x;
memcpy(&x, p, sizeof x);
return PyBool_FromLong(x != 0);
const _Bool f = false;

Check failure on line 500 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

‘f’ redeclared as different kind of symbol

Check failure on line 500 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

‘f’ redeclared as different kind of symbol

Check failure on line 500 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

‘f’ redeclared as different kind of symbol

Check failure on line 500 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build and test (x64)

redefinition of formal parameter 'f' [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check failure on line 500 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

redefinition of formal parameter 'f' [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check failure on line 500 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

redefinition of formal parameter 'f' [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]
return PyBool_FromLong(memcmp(p, &f, sizeof(_Bool));

Check failure on line 501 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

expected ‘)’ before ‘;’ token

Check failure on line 501 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

expected ‘;’ before ‘}’ token

Check failure on line 501 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

expected ‘)’ before ‘;’ token

Check failure on line 501 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

expected ‘;’ before ‘}’ token

Check failure on line 501 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

expected ‘)’ before ‘;’ token

Check failure on line 501 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

expected ‘;’ before ‘}’ token

Check failure on line 501 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build and test (x64)

syntax error: missing ')' before ';' [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check failure on line 501 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

syntax error: missing ')' before ';' [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check failure on line 501 in Modules/_struct.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

syntax error: missing ')' before ';' [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]
}


Expand Down
Loading