[3.14] gh-63161: Fix test_source_encoding when stderr is StringIO (GH-140361)

This commit is contained in:
Serhiy Storchaka 2025-10-20 20:05:42 +03:00 committed by GitHub
parent 6493a6aaf3
commit abb3b3142b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -521,7 +521,7 @@ def check_script_error(self, src, expected, lineno=...):
line = src.splitlines()[lineno-1].decode(errors='replace') line = src.splitlines()[lineno-1].decode(errors='replace')
if lineno == 1: if lineno == 1:
line = line.removeprefix('\ufeff') line = line.removeprefix('\ufeff')
line = line.encode(sys.stderr.encoding, sys.stderr.errors) line = line.encode(sys.__stderr__.encoding, sys.__stderr__.errors)
self.assertIn(line, err) self.assertIn(line, err)