Skip to content

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

PY3 disable scrapy.telnet if twisted.conch is not available

Mikhail Korobov378b6efc0e0f
diff --git a/scrapy/telnet.py b/scrapy/telnet.py
index d2617f69d..7b73a42ac 100644
--- a/scrapy/telnet.py
+++ b/scrapy/telnet.py
@@ -6,9 +6,13 @@ See documentation in docs/topics/telnetconsole.rst
import pprint
-from twisted.conch import manhole, telnet
-from twisted.conch.insults import insults
from twisted.internet import protocol
+try:
+ from twisted.conch import manhole, telnet
+ from twisted.conch.insults import insults
+ TWISTED_CONCH_AVAILABLE = True
+except ImportError:
+ TWISTED_CONCH_AVAILABLE = False
from scrapy.exceptions import NotConfigured
from scrapy import log, signals
@@ -32,6 +36,8 @@ class TelnetConsole(protocol.ServerFactory):
def __init__(self, crawler):
if not crawler.settings.getbool('TELNETCONSOLE_ENABLED'):
raise NotConfigured
+ if not TWISTED_CONCH_AVAILABLE:
+ raise NotConfigured
self.crawler = crawler
self.noisy = False
self.portrange = [int(x) for x in crawler.settings.getlist('TELNETCONSOLE_PORT')]
diff --git a/tests/py3-ignores.txt b/tests/py3-ignores.txt
index f3c667cd0..70cf22c79 100644
--- a/tests/py3-ignores.txt
+++ b/tests/py3-ignores.txt
@@ -97,5 +97,4 @@ scrapy/contrib/statsmailer.py
scrapy/contrib/memusage.py
scrapy/commands/deploy.py
scrapy/commands/bench.py
-scrapy/telnet.py
scrapy/mail.py