encode / httpx

A next generation HTTP client for Python. 🦋
https://www.python-httpx.org/
BSD 3-Clause "New" or "Revised" License
13.09k stars 834 forks source link

Allow pickling HTTPStatusError #3207

Open camillol opened 4 months ago

camillol commented 4 months ago

Summary

HTTPStatusError's __init__ method has required keyword-only arguments. BaseException has a custom __reduce__ method that can't handle that correctly. As a result, attempting to unpickle a pickled HTTPStatusError fails with:

TypeError: HTTPStatusError.init() missing 2 required keyword-only arguments: 'request' and 'response'

This PR fixes that by defining an appropriate __reduce__ method for HTTPStatusError.

Checklist

Note: I don't think this requires a documentation change, but let me know if so.