fix: Prevent mutation of default URL patterns list in `block_requests` by vdusek · Pull Request #1702 · apify/crawlee-python
When url_patterns was None, the code assigned it to the module-level _DEFAULT_BLOCK_REQUEST_URL_PATTERNS constant and then called extend() on it, permanently mutating the shared default list. This caused extra_url_patterns to accumulate across all subsequent calls that used the default patterns. Fixed by creating a copy of the list before extending it. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
added
t-tooling
labels
Jan 30, 2026labels
Jan 30, 2026
vdusek
changed the title
fix: Prevent mutation of default URL patterns list in block_requests
fix: Prevent mutation of default URL patterns list in block_requests
vdusek
deleted the
fix/block-requests-mutable-default
branch
Mantisus pushed a commit to Mantisus/crawlee-python that referenced this pull request
Feb 9, 2026apify#1702) When `url_patterns` was `None`, the code assigned it to the module-level `_DEFAULT_BLOCK_REQUEST_URL_PATTERNS` constant and then called `extend()` on it, permanently mutating the shared default list. This caused `extra_url_patterns` to accumulate across all subsequent calls that used the default patterns. Fixed by creating a copy of the list before extending it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters