Skip to content

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

dirname cannot be falsey

Matthew Donoughe69d1b8fc0832
diff --git a/scrapy/commands/runspider.py b/scrapy/commands/runspider.py
index ed16c3fb6..22fa6a53d 100644
--- a/scrapy/commands/runspider.py
+++ b/scrapy/commands/runspider.py
@@ -15,13 +15,11 @@ def _import_file(filepath: Union[str, PathLike]) -> ModuleType:
if abspath.suffix not in ('.py', '.pyw'):
raise ValueError(f"Not a Python source file: {abspath}")
dirname = str(abspath.parent)
- if dirname:
- sys.path = [dirname] + sys.path
+ sys.path = [dirname] + sys.path
try:
module = import_module(abspath.stem)
finally:
- if dirname:
- sys.path.pop(0)
+ sys.path.pop(0)
return module