Skip to content

Commit a258c96

Browse files
[3.14] gh-151284: Fix test_capi on UBSan (GH-151286) (#151324)
gh-151284: Fix test_capi on UBSan (GH-151286) Comment two checks relying on undefined behavior in test_fromwidechar() of test_capi. Enable test_capi in GitHub Action "Reusable Sanitizer". (cherry picked from commit d87d772) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 9f5c4c7 commit a258c96

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Lib/test/test_capi/test_unicode.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,16 +842,18 @@ def test_fromwidechar(self):
842842
if SIZEOF_WCHAR_T == 2:
843843
self.assertEqual(fromwidechar('a\U0001f600'.encode(encoding), 2), 'a\ud83d')
844844

845-
self.assertRaises(MemoryError, fromwidechar, b'', PY_SSIZE_T_MAX)
846845
self.assertRaises(SystemError, fromwidechar, b'\0'*SIZEOF_WCHAR_T, -2)
847-
self.assertRaises(SystemError, fromwidechar, b'\0'*SIZEOF_WCHAR_T, PY_SSIZE_T_MIN)
848846
self.assertEqual(fromwidechar(NULL, 0), '')
849847
self.assertRaises(SystemError, fromwidechar, NULL, 1)
850848
self.assertRaises(SystemError, fromwidechar, NULL, PY_SSIZE_T_MAX)
851849
self.assertRaises(SystemError, fromwidechar, NULL, -1)
852850
self.assertRaises(SystemError, fromwidechar, NULL, -2)
853851
self.assertRaises(SystemError, fromwidechar, NULL, PY_SSIZE_T_MIN)
854852

853+
# The following tests are skipped since they rely on undefined behavior
854+
#self.assertRaises(MemoryError, fromwidechar, b'', PY_SSIZE_T_MAX)
855+
#self.assertRaises(SystemError, fromwidechar, b'\0'*SIZEOF_WCHAR_T, PY_SSIZE_T_MIN)
856+
855857
@support.cpython_only
856858
@unittest.skipIf(_testlimitedcapi is None, 'need _testlimitedcapi module')
857859
def test_aswidechar(self):

0 commit comments

Comments
 (0)