vcrpy icon indicating copy to clipboard operation
vcrpy copied to clipboard

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

Open LilSpazJoekp opened this issue 2 years ago • 7 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

LilSpazJoekp avatar Jul 07 '23 17:07 LilSpazJoekp

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

hartwork avatar Jul 07 '23 18:07 hartwork

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

LilSpazJoekp avatar Jul 07 '23 18:07 LilSpazJoekp

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 avatar Jul 07 '23 18:07 LilSpazJoekp

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

hartwork avatar Jul 07 '23 18:07 hartwork

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

hartwork avatar Jul 07 '23 19:07 hartwork

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

LilSpazJoekp avatar Jul 07 '23 19:07 LilSpazJoekp