From 3dcfbf37457218cd014aa5a5fec42cb28e63ef33 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 21 May 2022 14:13:17 -0700 Subject: [PATCH] urllib.request: add code 308 handler for 3.11 (#7917) https://github.com/python/cpython/commit/c379bc5ec9012cf66424ef3d80612cf13ec51006 --- stdlib/urllib/request.pyi | 9 +++++++++ tests/stubtest_allowlists/py311.txt | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 5e6dde014..02ad1bd30 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -150,6 +150,10 @@ class HTTPRedirectHandler(BaseHandler): def http_error_302(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ... def http_error_303(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ... def http_error_307(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ... + if sys.version_info >= (3, 11): + def http_error_308( + self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage + ) -> _UrlopenRet | None: ... class HTTPCookieProcessor(BaseHandler): cookiejar: CookieJar @@ -330,6 +334,11 @@ class FancyURLopener(URLopener): def http_error_307( self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: bytes | None = ... ) -> _UrlopenRet | addinfourl | None: ... # undocumented + if sys.version_info >= (3, 11): + def http_error_308( + self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: bytes | None = ... + ) -> _UrlopenRet | addinfourl | None: ... # undocumented + def http_error_401( self, url: str, diff --git a/tests/stubtest_allowlists/py311.txt b/tests/stubtest_allowlists/py311.txt index 9bb3ebc72..a1c0c9764 100644 --- a/tests/stubtest_allowlists/py311.txt +++ b/tests/stubtest_allowlists/py311.txt @@ -90,8 +90,6 @@ typing.TypeVarTuple.__typing_subst__ unittest.TestCase._addSkip unittest.case.TestCase._addSkip unittest.doModuleCleanups -urllib.request.FancyURLopener.http_error_308 -urllib.request.HTTPRedirectHandler.http_error_308 weakref.WeakValueDictionary.update xmlrpc.server.SimpleXMLRPCRequestHandler.rpc_paths