gh-99941: Ensure that asyncio.Protocol.data_received receives immutable bytes (#100053)

This commit is contained in:
DarioDaF 2022-12-11 00:07:02 +01:00 committed by GitHub
parent d5f8a2b6ad
commit 1bb68ba6d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 4 deletions

View file

@ -75,7 +75,10 @@ class ProactorSocketTransportTests(test_utils.TestCase):
called_buf = bytearray(self.buffer_size)
called_buf[:len(buf)] = buf
self.loop._proactor.recv_into.assert_called_with(self.sock, called_buf)
self.protocol.data_received.assert_called_with(bytearray(buf))
self.protocol.data_received.assert_called_with(buf)
# assert_called_with maps bytearray and bytes to the same thing so check manually
# regression test for https://github.com/python/cpython/issues/99941
self.assertIsInstance(self.protocol.data_received.call_args.args[0], bytes)
@unittest.skipIf(sys.flags.optimize, "Assertions are disabled in optimized mode")
def test_loop_reading_no_data(self):