mirror of https://github.com/scrapy/scrapy.git
Fix cell-var-from-loop in _send_catch_log_deferred
Replace lambda capturing receiver by reference with a default argument to capture it by value, fixing a potential bug where all deferred callbacks could reference the last receiver in the loop instead of their respective receivers. Removes the pylint disable comment and TODO that were suppressing this issue.
This commit is contained in:
parent
75f05d4e80
commit
9a74399792
|
|
@ -125,12 +125,8 @@ def _send_catch_log_deferred(
|
|||
**named,
|
||||
)
|
||||
d.addErrback(logerror, receiver)
|
||||
# TODO https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/cell-var-from-loop.html
|
||||
d2: Deferred[tuple[TypingAny, TypingAny]] = d.addBoth(
|
||||
lambda result: (
|
||||
receiver, # pylint: disable=cell-var-from-loop # noqa: B023
|
||||
result,
|
||||
)
|
||||
lambda result, recv=receiver: (recv, result)
|
||||
)
|
||||
dfds.append(d2)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue