diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py index 38097dbdfb97e4..a2b5997067539e 100644 --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -147,9 +147,9 @@ def test_flock_overflow(self): @unittest.skipIf(sys.platform != 'darwin', "F_GETPATH is only available on macos") def test_fcntl_f_getpath(self): self.f = open(TESTFN, 'wb') - abspath = os.path.abspath(TESTFN) - res = fcntl.fcntl(self.f.fileno(), fcntl.F_GETPATH, bytes(len(abspath))) - self.assertEqual(abspath, res.decode('utf-8')) + expected = os.path.abspath(TESTFN).encode('utf-8') + res = fcntl.fcntl(self.f.fileno(), fcntl.F_GETPATH, bytes(len(expected))) + self.assertEqual(expected, res) def test_main(): run_unittest(TestFcntl)