]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43651: Fix EncodingWarning in test_warnings (GH-25126)
authorInada Naoki <songofacandy@gmail.com>
Thu, 1 Apr 2021 23:57:05 +0000 (08:57 +0900)
committerGitHub <noreply@github.com>
Thu, 1 Apr 2021 23:57:05 +0000 (08:57 +0900)
Lib/test/test_warnings/__init__.py

index 04f7560ecc09c172f539eef2bbf1157b4e236dde..4b1b4e193cb165b45a70e609ac96666dc75c93d6 100644 (file)
@@ -935,10 +935,10 @@ class PyWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
     def test_tracemalloc(self):
         self.addCleanup(os_helper.unlink, os_helper.TESTFN)
 
-        with open(os_helper.TESTFN, 'w') as fp:
+        with open(os_helper.TESTFN, 'w', encoding="utf-8") as fp:
             fp.write(textwrap.dedent("""
                 def func():
-                    f = open(__file__)
+                    f = open(__file__, "rb")
                     # Emit ResourceWarning
                     f = None
 
@@ -973,7 +973,7 @@ class PyWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
               File "{filename}", lineno 7
                 func()
               File "{filename}", lineno 3
-                f = open(__file__)
+                f = open(__file__, "rb")
         ''').strip()
         self.assertEqual(stderr, expected)