kevin1024 / vcrpy

Automatically mock your HTTP interactions to simplify and speed up testing
MIT License
2.72k stars 389 forks source link

[>=4.4.0] Uploading file with aiohttp seems broken: TypeError: cannot pickle '_io.BufferedReader' object #737

Open LilSpazJoekp opened 1 year ago

LilSpazJoekp commented 1 year ago

When uploading files with aiohttp, the following error occurs.

Suspect commit.

Error

TypeError: cannot pickle '_io.BufferedReader' object

aiohttp code to reproduce:

async def upload_file():
    async with aiohttp.ClientSession() as session:
        with open("run.sh", "rb") as f:
            response = await session.post("https://example.com", data={"file": f})

See failed tests here: https://github.com/praw-dev/asyncpraw/pull/246/checks#step:6:5393

hartwork commented 1 year ago

Hi @LilSpazJoekp is my understanding correct that this worked with 4.3.0 for you previously?

I'm not sure right now what we can do about these requests not being deepcopy-able. Maybe catch the exception and continue with the original — not sure how bad of an idea that is.

CC #174 #702 @abramclark @kevin1024

LilSpazJoekp commented 1 year ago

No this worked with 4.2.1 and stopped working with 4.3.0 and on.

LilSpazJoekp commented 1 year ago

Correction. Not working on 4.3.0 was due to urllib3 issues. After fixing those this worked on 4.3.0 but not on 4.4.0.

hartwork commented 1 year ago

@LilSpazJoekp I see, thanks for the clarification :+1:

hartwork commented 1 year ago

@LilSpazJoekp potentially important to know: If this is fixed it will be fixed in a release VCR.py >=5.0.1 with support for >=Python 3.8 only. Your CI shows still shows use of end-of-life Python 3.7 which is why I'm bringing this up.

LilSpazJoekp commented 1 year ago

That's fine. We plan on dropping 3.7 soon. I thought EOL was later in the year.