Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

asyncio tcp transport on Windows reads bytearray instead of bytes #99941

Closed
Labels
@DarioDaF

Description

@DarioDaF

Bug report

asyncio.Protocol.data_received prototype not respected: when usingcreate_connection to create a tcp transportdata_received is being called with abytearray object instead ofbytes.
If this is expected behaviour libraries like httpx and such should be warned or the prototype modified, although I doubt it's intended because it would suppose the generator doesn't hold reference to it otherwise data could change while stored in buffered stuff.

importsysprint(f'Python:{sys.version}\n')importasyncioclassMyProto(asyncio.Protocol):defdata_received(self,data:bytes)->None:print('@@@@@@@@@@ ',data)defeof_received(self):print('##########')asyncdefmain():t,proto=awaitasyncio.get_running_loop().create_connection(MyProto,'example.com',80)t.write(b'SITE BE MAD\n\n')awaitasyncio.sleep(1)t.close()asyncio.run(main())

Correct output:@@@@@@@@@@ b'HTTP/1.0 ...WHATEVER THE SERVER ANSWERS...'
Faulty output:@@@@@@@@@@ bytearray(b'HTTP/1.0 ...WHATEVER THE SERVER ANSWERS...')

Your environment

On Windows 11 x64

Tested on:

  • 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
  • 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]

Working as expected in:

  • 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)]

Related problems

Link to the thread where I found a conflicting thing (it's being solved there as a workaround)
encode/httpx#2305 (comment)

EDIT: simplified the minimal example

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp