kevin1024 / vcrpy

Automatically mock your HTTP interactions to simplify and speed up testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

LilSpazJoekp opened this issue · comments

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

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

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

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.

@LilSpazJoekp I see, thanks for the clarification 👍

@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.

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