Skip to content

Commit 036fc7d

Browse files
authored
bpo-43651: Fix EncodingWarning in test_warnings (GH-25126)
1 parent bd4ab8e commit 036fc7d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/test/test_warnings/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -935,10 +935,10 @@ class PyWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
935935
def test_tracemalloc(self):
936936
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
937937

938-
with open(os_helper.TESTFN, 'w') as fp:
938+
with open(os_helper.TESTFN, 'w', encoding="utf-8") as fp:
939939
fp.write(textwrap.dedent("""
940940
def func():
941-
f = open(__file__)
941+
f = open(__file__, "rb")
942942
# Emit ResourceWarning
943943
f = None
944944
@@ -973,7 +973,7 @@ def run(*args):
973973
File "{filename}", lineno 7
974974
func()
975975
File "{filename}", lineno 3
976-
f = open(__file__)
976+
f = open(__file__, "rb")
977977
''').strip()
978978
self.assertEqual(stderr, expected)
979979

0 commit comments

Comments
 (0)