]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/networking/_urllib.py
[core] Fix support for upcoming Python 3.12 (#8130)
[yt-dlp.git] / yt_dlp / networking / _urllib.py
index b3e705b8448d7d3732d98c103d52a17bc8fae3b0..3c0647ecf909b4e0bbd0d25ab6a1c52a85f11171 100644 (file)
@@ -429,7 +429,7 @@ def _send(self, request):
         except urllib.error.HTTPError as e:
             if isinstance(e.fp, (http.client.HTTPResponse, urllib.response.addinfourl)):
                 # Prevent file object from being closed when urllib.error.HTTPError is destroyed.
-                e._closer.file = None
+                e._closer.close_called = True
                 raise HTTPError(UrllibResponseAdapter(e.fp), redirect_loop='redirect error' in str(e)) from e
             raise  # unexpected
         except urllib.error.URLError as e: