Scrapy, a fast high-level web crawling & scraping framework for Python.
Fix FileFeedStorage handling of Windows paths without file:// scheme (#6897)
Thalison Fernandes5e20b46e35c3
diff --git a/scrapy/extensions/feedexport.py b/scrapy/extensions/feedexport.pyindex 8bcd4e40d..4ac546765 100644--- a/scrapy/extensions/feedexport.py+++ b/scrapy/extensions/feedexport.py@@ -185,7 +185,7 @@ class StdoutFeedStorage:@implementer(IFeedStorage)class FileFeedStorage:def __init__(self, uri: str, *, feed_options: dict[str, Any] | None = None):- self.path: str = file_uri_to_path(uri)+ self.path: str = file_uri_to_path(uri) if uri.startswith("file://") else urifeed_options = feed_options or {}self.write_mode: OpenBinaryMode = ("wb" if feed_options.get("overwrite", False) else "ab"diff --git a/tests/test_feedexport.py b/tests/test_feedexport.pyindex 44cd10ec3..7c6425f19 100644--- a/tests/test_feedexport.py+++ b/tests/test_feedexport.py@@ -143,6 +143,11 @@ class TestFileFeedStorage(unittest.TestCase):finally:path.unlink()+ def test_preserves_windows_path_without_file_scheme(self):+ path = r"C:\Users\user\Desktop\test.txt"+ storage = FileFeedStorage(path)+ assert storage.path == path+class TestFTPFeedStorage(unittest.TestCase):def get_test_spider(self, settings=None):