Commit Graph

11217 Commits

Author SHA1 Message Date
Adrian Chaves ba8bb9e4e9 WIP 2026-06-30 12:53:18 +02:00
Adrian Chaves e0cc7ed7db WIP 2026-06-30 11:33:37 +02:00
Adrian Chaves 80f161ef3e Merge remote-tracking branch 'origin/master' into throttling 2026-06-30 08:23:04 +02:00
Andrey Rakhmatullin 52147017b4
Cleanup cookie handling in request_to_curl() (#7684)
* Adjust CookiesT.

* Drop list of plain cookie dicts support from request_to_curl().

* Extract _decode_cookie().

* Unify logging.

* Extract _to_verbose_cookies().

* Sync and type hint _cookie_to_set_cookie_value() in tests.

* Add tests for bytes in Request.cookies.

* Type hint assertCookieValEqual().
2026-06-29 21:49:09 +05:00
tanishqtayade 6591cb756c
Fix to LocalCache with limit=0 still stores items rather than disabling the cache (#7663)
* 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.

* chore: trigger CI rerun for mypy network error

* Fix mypy error: pass receiver via addBoth args instead of lambda default

* style: apply pre-commit ruff formatting

* fix: LocalCache with limit=0 incorrectly stores items

When limit=0 is passed to LocalCache (e.g. when DNSCACHE_ENABLED=False),
the condition 'if self.limit' evaluates to False due to Python's truthiness
rules, causing items to be stored despite the cache being disabled.

This leads to an unbounded memory leak during long crawls when DNS caching
is explicitly disabled.

Fix changes the condition to 'if self.limit is not None' and adds an early
return when limit=0 to correctly handle the disabled cache case.

* test: add resolver-level regression tests for DNSCACHE_ENABLED=False

Add two regression tests that verify DNS results are not stored in
dnscache when DNSCACHE_ENABLED=False (cache_size=0):

- test_caching_hostname_resolver_dnscache_disabled_rejects_storage:
  verifies _CachingResolutionReceiver does not write to dnscache
  when CachingHostnameResolver is initialized with cache_size=0

- test_caching_threaded_resolver_dnscache_disabled_rejects_storage:
  verifies dnscache rejects storage at the LocalCache level
  when limit=0

* test: drop misleading threaded resolver test

it was writing directly to dnscache, not actually going through
CachingThreadedResolver at all. the threaded resolver already has
its own if dnscache.limit: guard so the bug doesnt affect it anyway.

keeping only the hostname resolver test which covers the actual
bug path through _CachingResolutionReceiver

* test: clean up comments in resolver test

* test: remove unnecessary comment
2026-06-29 21:37:06 +05:00
Adrian Chaves 8dfb548415 WIP 2026-06-29 16:29:31 +02:00
Javier 4b2b56f384
Update on Request objects (#7286) 2026-06-29 15:34:12 +02:00
Adrian 9559cbee1e
Solve timing issues with HTTP cache tests? (#7692) 2026-06-29 17:21:20 +05:00
Adrian Chaves 184166d629 Use get_* for getters 2026-06-29 10:58:18 +02:00
Adrian Chaves 7a211960c9 Merge remote-tracking branch 'origin/master' into throttling 2026-06-29 10:47:28 +02:00
Adrian Chaves 8834250059 WIP 2026-06-26 22:53:11 +02:00
greymoth 185d6b9a20
Fix request_to_curl() corrupting dict cookies with bytes keys/values (#7675)
* Fix request_to_curl() corrupting dict cookies with bytes keys/values

PR #7603 made the list-cookie branch of request_to_curl() bytes-safe via
_cookie_value_to_unicode(), but left the sibling dict-cookie branch using
raw f-string interpolation. A dict cookie with bytes keys/values (a
supported and common form, e.g. Request(url, cookies={b"k": b"v"})) was
rendered as --cookie 'b'k'=b'v'' instead of --cookie 'k=v', producing a
broken curl command.

Route the dict branch through the same _cookie_value_to_unicode() helper,
mirroring the list branch. Add a regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: apply _cookie_value_to_unicode to list-branch cookie key/value

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 00:53:32 +05:00
Adrian Chaves d23c44858a Address issues 2026-06-26 21:41:45 +02:00
Andrey Rakhmatullin 4b40d2d06a
Close various garbage collectible resources (mostly in tests) (#7644)
* Set TELNETCONSOLE_ENABLED=False in get_crawler().

* Make _get_console_and_portal() a context manager.

* Allow PYTHONTRACEMALLOC in tox.

* Close the event loop in test_custom_asyncio_loop_enabled_false().

* Close the handler in _uninstall_scrapy_root_handler().

* Close queues in test_squeues.py.

* Close empty queues in init_prios().

* Close PopenSpawn stdin and stdout explicitly.

* Silence the unclosed socket warning.

* Implement more methods in CustomStatsCollector.

* Link the Twisted issue.

* Close the connection on download_maxsize.

* Fix typing.

* Add a comment about CustomStatsCollector.

* Restore the coverage.

* Properly close fixture queues.

* More robust file closing in feed storages.

* Close the file in TestMarshalItemExporter.test_nonstring_types_item().

* Cleanup temporary file handling in test_exporters.py.

* Close the file in test_stats_file_failed().

* Use an explicit TextIOWrapper in XmlItemExporter.
2026-06-26 23:05:08 +05:00
Adrian Chaves fb031dee80 Merge remote-tracking branch 'origin/master' into throttling 2026-06-26 19:01:20 +02:00
Adrian Chaves 5aae8334a5 Improve request and scope delay support 2026-06-26 19:00:06 +02:00
Adrian cf5607f8bc
Undeprecated the basic FormRequest API (#7671) 2026-06-26 17:35:46 +02:00
Adrian edc353c975
Improve test coverage for shell/ (#7680)
* Improve test coverage for shell/

* Address test issues

* Make the shell config test more reliable on Windows
2026-06-26 19:40:36 +05:00
Adrian Chaves ee8c5f7aa4 Fix two environment-specific test failures 2026-06-26 16:00:11 +02:00
Adrian Chaves aeb6b4763c Merge remote-tracking branch 'origin/master' into throttling 2026-06-26 14:47:23 +02:00
Adrian Chaves 4a7a2d5b5f Improve test coverage 2026-06-26 14:39:13 +02:00
Adrian Chaves 8caa1ac4db Fix typing issues 2026-06-26 13:27:14 +02:00
Adrian 1b940a75ac
Improve the item pipeline docs (#7676) 2026-06-26 16:18:22 +05:00
Adrian Chaves c889c1057d Improve test coverage 2026-06-26 13:09:17 +02:00
Adrian Chaves 627cecc93e Merge remote-tracking branch 'origin/master' into throttling 2026-06-26 12:17:22 +02:00
Adrian Chaves 6ce90dde3e Minimum queuelib: 1.4.2 → 1.6.1 2026-06-26 12:15:52 +02:00
Adrian 7ab404c725
Add a documentation page about security (#7678) 2026-06-26 11:58:37 +02:00
Adrian 0ccddb4f61
Improve test coverage for contracts (#7677) 2026-06-26 11:47:30 +02:00
Adrian Chaves 3e02b9e5ab Merge remote-tracking branch 'origin/master' into throttling 2026-06-26 11:32:43 +02:00
Adrian Chaves 8190b5b703 Add a throttling-aware scheduler 2026-06-26 10:44:31 +02:00
Adrian 0007676e8d
Improve test coverage for http/ (#7672)
* Improve test coverage for http/

* Use isinstance() instead of type()
2026-06-26 12:21:12 +05:00
Sriniketh24 d8d7de2339
Fix FTPDownloadHandler not closing FTP connection after download (#7667) 2026-06-26 04:26:59 +02:00
Adrian Chaves ec18ddc239 Initial implementation draft 2026-06-25 16:01:47 +02:00
Adrian 74e6b61071
Make DOWNLOADER_CLIENT_TLS_CIPHERS=None enable Twisted defaults (#7665)
* Make DOWNLOADER_CLIENT_TLS_CIPHERS=None enable Twisted defaults

* Remove pointless comment

* Remove unnecessary mypy comments
2026-06-25 16:44:51 +05:00
Adrian Chaves 4af625ac1b Merge remote-tracking branch 'origin/master' into throttling 2026-06-25 13:39:28 +02:00
Adrian Chaves 7fdee93e42 WIP 2026-06-25 13:38:55 +02:00
Adrian c690eac770
Document “logging settings” as special settings (#7668) 2026-06-25 16:34:37 +05:00
Adrian 65e8954a06
Improve test coverage for spider middlewares (#7664) 2026-06-25 15:35:25 +05:00
Adrian dd4549e6f9
Improve test coverage for downloader middlewares (#7655)
* Improve test coverage for downloader middlewares

* Improve coverage further
2026-06-25 01:48:28 +05:00
Adrian Chaves c93e430ccb Complete docs 2026-06-24 13:35:07 +02:00
Adrian Chaves d18085dc3e Update docs 2026-06-24 11:49:51 +02:00
Adrian Chaves d8d519367d Fix docs/requirements.txt 2026-06-24 10:57:56 +02:00
Adrian Chaves b6bc947cce scrapy/addons.py → scrapy/addons/__init__.py 2026-06-24 10:37:42 +02:00
Adrian Chaves e796beb6fa Merge remote-tracking branch 'origin/master' into throttling 2026-06-24 10:27:28 +02:00
Adrian b78ab3d6c8
Improve test coverage for settings/ (#7654) 2026-06-23 14:47:21 +05:00
smellslikeml fb3455304d
Add content-based image filtering example (#4954) 2026-06-23 09:04:19 +02:00
tanishqtayade f5a62a293f
Fix cell-var-from-loop bug in _send_catch_log_deferred (#7649) 2026-06-23 09:04:01 +02:00
Adrian f605defefc
Document scrapy-lint, remove start_url check (#7627)
* Document scrapy-lint, remove start_url check

* Remove the offsite URL check in favor of scrapy-lint
2026-06-22 20:12:16 +05:00
Adrian 7499d17e28
Improve test coverage for responsetypes.py (#7646)
* Improve test coverage for responsetypes.py

* Solve typing issues
2026-06-22 20:10:38 +05:00
Adrian b6596de317
Do not ignore CrawlerProcess settings (#7647)
* Do not ignore CrawlerProcess settings

* Update test_crawlerrunner_accepts_crawler
2026-06-22 20:10:10 +05:00