httpx icon indicating copy to clipboard operation
httpx copied to clipboard

Allow pickling HTTPStatusError

Open camillol opened this issue 1 year ago • 10 comments
trafficstars

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

  • [x] I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • [x] I've updated the documentation accordingly.

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

camillol avatar May 22 '24 14:05 camillol