Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Correctly wrap connection errors into ResponseFailed.

Andrey Rakhmatullin3dd9d71c328f
diff --git a/scrapy/core/http2/agent.py b/scrapy/core/http2/agent.py
index 75731f525..215ea9716 100644
--- a/scrapy/core/http2/agent.py
+++ b/scrapy/core/http2/agent.py
@@ -6,7 +6,12 @@ from twisted.internet.base import ReactorBase
from twisted.internet.defer import Deferred
from twisted.internet.endpoints import HostnameEndpoint
from twisted.python.failure import Failure
-from twisted.web.client import URI, BrowserLikePolicyForHTTPS, _StandardEndpointFactory
+from twisted.web.client import (
+ URI,
+ BrowserLikePolicyForHTTPS,
+ ResponseFailed,
+ _StandardEndpointFactory,
+)
from twisted.web.error import SchemeNotSupported
from scrapy.core.downloader.contextfactory import AcceptableProtocolsContextFactory
@@ -83,8 +88,7 @@ class H2ConnectionPool:
pending_requests = self._pending_requests.pop(key, None)
while pending_requests:
d = pending_requests.popleft()
- # TODO: this is incorrect, errback takes a single exception
- d.errback(errors) # type: ignore[arg-type]
+ d.errback(ResponseFailed(errors))
def close_connections(self) -> None:
"""Close all the HTTP/2 connections and remove them from pool