Raise valueerrors

This commit is contained in:
Stan Ulbrych 2025-07-13 07:55:11 +01:00
parent 609d5adc7c
commit cb8197ad6d
No known key found for this signature in database
GPG key ID: B8E58DBDB2A1A0B8
8 changed files with 52 additions and 16 deletions

View file

@ -3128,6 +3128,18 @@ def test_uu_invalid(self):
# Missing "begin" line
self.assertRaises(ValueError, codecs.decode, b"", "uu-codec")
def test_invalid_error_input(self):
# decoders/encoders require errors == 'strict'
for encoding in bytes_transform_encodings:
with self.subTest(encoding=encoding):
encoder = codecs.getencoder(encoding)
decoder = codecs.getdecoder(encoding)
self.assertRaises(ValueError, encoder, 'in', errors='notstrict')
self.assertRaises(ValueError, decoder, 'in', errors='notstrict')
# The codec system tries to add notes to exceptions in order to ensure
# the error mentions the operation being performed and the codec involved.