gurudesh/pytracebugs huggingface dataset:
# Buggy code
def file_path(self, request, response=None, info=None):
    media_guid = hashlib.sha1(to_bytes(request.url)).hexdigest()
    media_ext = os.path.splitext(request.url)[1]
    return "full/%s%s" % (media_guid, media_ext)


# Traceback (OSError)
Traceback (most recent call last):
File "c:\program files\python37\lib\site-packages\scrapy\pipelines\files.py", line 419, in media_downloaded
checksum = self.file_downloaded(response, request, info)
File "c:\program files\python37\lib\site-packages\scrapy\pipelines\files.py", line 452, in file_downloaded
self.store.persist_file(path, buf, info)
File "c:\program files\python37\lib\site-packages\scrapy\pipelines\files.py", line 53, in persist_file
with open(absolute_path, 'wb') as f:
OSError: [Errno 22] Invalid argument: 'E:\\2019-08-12\\resources\\885443110bae0e1149e017dbea5ca3935efa38c0.com%2Fimages%2Fdimse%2F5845cadfecd996e0372f%2F108a4af73772ae197fa2c4ec4e9fe7a47390433c%2FY3JvcD0xMTc0JTJDNTgwJTJDMCUyQzAmcXVhbGl0eT04NSZmb3JtYXQ9anBnJnJlc2l6ZT0xNjAwJTJDNzkxJmltYWdlX3VyaT1odHRwcyUzQSUyRiUyRnMueWltZy5jb20lMkZvcyUyRmNyZWF0ci11cGxvYWRlZC1pbWFnZXMlMkYyMDE5LTA4JTJGMWJmZGQxNDAtYjliYy0xMWU5LWJmZjMtMjMyNzcwMTg1MzE5JmNsaWVudD1hMWFjYWMzZTFiMzI5MDkxN2Q5MiZzaWduYXR1cmU9OTFiNzQ3Y2MyZTY5ODY3OGIxNWI0OTkyMjdjM2NmZWRlYTE1NGIxOA%3D%3D&amp;client=a1acac3e1b3290917d92&amp;signature=6517aece82e79d536edeaccc275ad88090df0252'

# Fixed code
def file_path(self, request, response=None, info=None):
    media_guid = hashlib.sha1(to_bytes(request.url)).hexdigest()
    media_ext = os.path.splitext(request.url)[1]
    # Handles empty and wild extensions by trying to guess the
    # mime type then extension or default to empty string otherwise
    if media_ext not in mimetypes.types_map:
        media_ext = ""
        media_type = mimetypes.guess_type(request.url)[0]
        if media_type:
            media_ext = mimetypes.guess_extension(media_type)
    return "full/%s%s" % (media_guid, media_ext)
# Buggy code
def _pickle_serialize(obj):
    try:
        return pickle.dumps(obj, protocol=2)
    # Python>=3.5 raises AttributeError here while
    # Python<=3.4 raises pickle.PicklingError
    except (pickle.PicklingError, AttributeError) as e:
        raise ValueError(str(e))


# Traceback (AssertionError)
root@04bfc6cf84cd:/# scrapy version -v
Scrapy    : 1.3.3
lxml      : 3.7.2.0
libxml2   : 2.9.3
cssselect : 1.0.1
parsel    : 1.1.0
w3lib     : 1.17.0
Twisted   : 16.6.0
Python    : 2.7.14 (default, Dec 12 2017, 16:55:09) - [GCC 4.9.2]
pyOpenSSL : 16.2.0 (OpenSSL 1.0.1t  3 May 2016)
Platform  : Linux-4.9.44-linuxkit-aufs-x86_64-with-debian-8.10
root@04bfc6cf84cd:/# scrapy shell "http://example.org"
2017-12-29 16:49:27 [scrapy.utils.log] INFO: Scrapy 1.3.3 started (bot: scrapybot)
(...)
from six.moves import cPickle as pickle
s2 = pickle.loads(pickle.dumps(response.selector, protocol=2))
response.selector.css('a')
[<Selector xpath=u'descendant-or-self::a' data=u'<a href="http://www.iana.org/domains/exa'>]
s2.css('a')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/parsel/selector.py", line 227, in css
return self.xpath(self._css2xpath(query))
File "/usr/local/lib/python2.7/site-packages/parsel/selector.py", line 203, in xpath
**kwargs)
File "src/lxml/lxml.etree.pyx", line 1584, in lxml.etree._Element.xpath (src/lxml/lxml.etree.c:59349)
File "src/lxml/xpath.pxi", line 257, in lxml.etree.XPathElementEvaluator.__init__ (src/lxml/lxml.etree.c:170478)
File "src/lxml/apihelpers.pxi", line 19, in lxml.etree._assertValidNode (src/lxml/lxml.etree.c:16482)
AssertionError: invalid Element proxy at 140144569743064

# Fixed code
def _pickle_serialize(obj):
    try:
        return pickle.dumps(obj, protocol=2)
    # Python <= 3.4 raises pickle.PicklingError here while
    # 3.5 <= Python < 3.6 raises AttributeError and
    # Python >= 3.6 raises TypeError
    except (pickle.PicklingError, AttributeError, TypeError) as e:
        raise ValueError(str(e))
# Buggy code
def getHostByName(self, name, timeout=None):
    if name in dnscache:
        return defer.succeed(dnscache[name])
    # in Twisted<=16.6, getHostByName() is always called with
    # a default timeout of 60s (actually passed as (1, 3, 11, 45) tuple),
    # so the input argument above is simply overridden
    # to enforce Scrapy's DNS_TIMEOUT setting's value
    timeout = (self.timeout,)
    d = super(CachingThreadedResolver, self).getHostByName(name, timeout)
    d.addCallback(self._cache_result, name)
    return d


# Traceback (KeyError)
2017-07-03 03:09:12 [twisted] CRITICAL: while looking up www.mydomain.com with <scrapy.resolver.CachingThreadedResolver object at 0x3fd0050>
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 653, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/usr/lib64/python2.7/site-packages/scrapy/resolver.py", line 29, in _cache_result
dnscache[name] = result
File "/usr/lib64/python2.7/site-packages/scrapy/utils/datatypes.py", line 305, in __setitem__
self.popitem(last=False)
File "/usr/lib64/python2.7/collections.py", line 159, in popitem
raise KeyError('dictionary is empty')
KeyError: 'dictionary is empty'
2017-07-03 03:09:12 [scrapy.downloadermiddlewares.retry] DEBUG: Gave up retrying <GET //www.mydomain.com/> (failed 3 times): DNS lookup failed: no results for hostname lookup: www.mydomain.com.
Traceback (most recent call last):
File "/usr/bin/scrapy", line 11, in <module>
sys.exit(execute())
File "/usr/lib64/python2.7/site-packages/scrapy/cmdline.py", line 149, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/usr/lib64/python2.7/site-packages/scrapy/cmdline.py", line 89, in _run_print_help
func(*a, **kw)
File "/usr/lib64/python2.7/site-packages/scrapy/cmdline.py", line 156, in _run_command
cmd.run(args, opts)
File "/usr/lib64/python2.7/site-packages/scrapy/commands/shell.py", line 73, in run
shell.start(url=url, redirect=not opts.no_redirect)
File "/usr/lib64/python2.7/site-packages/scrapy/shell.py", line 48, in start
self.fetch(url, spider, redirect=redirect)
File "/usr/lib64/python2.7/site-packages/scrapy/shell.py", line 115, in fetch
reactor, self._schedule, request, spider)
File "/usr/lib64/python2.7/site-packages/twisted/internet/threads.py", line 122, in blockingCallFromThread
result.raiseException()
File "<string>", line 2, in raiseException
twisted.internet.error.DNSLookupError: DNS lookup failed: no results for hostname lookup: www.mydomain.com.

# Fixed code
def getHostByName(self, name, timeout=None):
    if name in dnscache:
        return defer.succeed(dnscache[name])
    # in Twisted<=16.6, getHostByName() is always called with
    # a default timeout of 60s (actually passed as (1, 3, 11, 45) tuple),
    # so the input argument above is simply overridden
    # to enforce Scrapy's DNS_TIMEOUT setting's value
    timeout = (self.timeout,)
    d = super(CachingThreadedResolver, self).getHostByName(name, timeout)
    if dnscache.limit:
        d.addCallback(self._cache_result, name)
    return d
# Buggy code
def process_response(self, request, response, spider):
    if request.method == "HEAD":
        return response
    if isinstance(response, Response):
        content_encoding = response.headers.getlist("Content-Encoding")
        if content_encoding and not is_gzipped(response):
            encoding = content_encoding.pop()
            decoded_body = self._decode(response.body, encoding.lower())
            respcls = responsetypes.from_args(
                headers=response.headers, url=response.url
            )
            kwargs = dict(cls=respcls, body=decoded_body)
            if issubclass(respcls, TextResponse):
                # force recalculating the encoding until we make sure the
                # responsetypes guessing is reliable
                kwargs["encoding"] = None
            response = response.replace(**kwargs)
            if not content_encoding:
                del response.headers["Content-Encoding"]

    return response


# Traceback (TypeError)
Traceback (most recent call last):
File "twisted/internet/defer.py", line 1128, in _inlineCallbacks
result = g.send(result)
File "scrapy/core/downloader/middleware.py", line 53, in process_response
spider=spider)
File "scrapy/downloadermiddlewares/httpcompression.py", line 38, in process_response
response = response.replace(**kwargs)
File "scrapy/http/response/text.py", line 50, in replace
return Response.replace(self, *args, **kwargs)
File "scrapy/http/response/__init__.py", line 77, in replace
return cls(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'encoding'

# Fixed code
def process_response(self, request, response, spider):
    if request.method == "HEAD":
        return response
    if isinstance(response, Response):
        content_encoding = response.headers.getlist("Content-Encoding")
        if content_encoding and not is_gzipped(response):
            encoding = content_encoding.pop()
            decoded_body = self._decode(response.body, encoding.lower())
            respcls = responsetypes.from_args(
                headers=response.headers, url=response.url, body=decoded_body
            )
            kwargs = dict(cls=respcls, body=decoded_body)
            if issubclass(respcls, TextResponse):
                # force recalculating the encoding until we make sure the
                # responsetypes guessing is reliable
                kwargs["encoding"] = None
            response = response.replace(**kwargs)
            if not content_encoding:
                del response.headers["Content-Encoding"]

    return response
# Buggy code
def __init__(self, setting):
    pass


# Traceback (KeyError)
$ scrapy version -v
Scrapy    : 1.2.0
lxml      : 3.6.4.0
libxml2   : 2.9.4
Twisted   : 16.4.1
Python    : 2.7.12 (default, Jul  1 2016, 15:12:24) - [GCC 5.4.0 20160609]
pyOpenSSL : 16.1.0 (OpenSSL 1.0.2g  1 Mar 2016)
Platform  : Linux-4.4.0-43-generic-x86_64-with-Ubuntu-16.04-xenial


$ scrapy shell ftp://ftp.eu.metabrainz.org/pub/musicbrainz/data/fullexport/20161019-001816/MD5SUMS
2016-10-20 16:01:27 [scrapy] INFO: Scrapy 1.2.0 started (bot: scrapybot)
(...)
2016-10-20 16:01:27 [scrapy] INFO: Spider opened
Traceback (most recent call last):
File "/home/paul/.virtualenvs/scrapy12/bin/scrapy", line 11, in <module>
sys.exit(execute())
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/cmdline.py", line 142, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/cmdline.py", line 88, in _run_print_help
func(*a, **kw)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/cmdline.py", line 149, in _run_command
cmd.run(args, opts)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/commands/shell.py", line 71, in run
shell.start(url=url)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/shell.py", line 47, in start
self.fetch(url, spider)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/shell.py", line 112, in fetch
reactor, self._schedule, request, spider)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/twisted/internet/threads.py", line 122, in blockingCallFromThread
result.raiseException()
File "<string>", line 2, in raiseException
KeyError: 'ftp_user'

# Fixed code
def __init__(self, settings):
    self.default_user = settings["FTP_USER"]
    self.default_password = settings["FTP_PASSWORD"]
    self.passive_mode = settings["FTP_PASSIVE_MODE"]
# Buggy code
def download_request(self, request, spider):
    parsed_url = urlparse(request.url)
    creator = ClientCreator(
        reactor,
        FTPClient,
        request.meta["ftp_user"],
        request.meta["ftp_password"],
        passive=request.meta.get("ftp_passive", 1),
    )
    return creator.connectTCP(parsed_url.hostname, parsed_url.port or 21).addCallback(
        self.gotClient, request, unquote(parsed_url.path)
    )


# Traceback (KeyError)
$ scrapy version -v
Scrapy    : 1.2.0
lxml      : 3.6.4.0
libxml2   : 2.9.4
Twisted   : 16.4.1
Python    : 2.7.12 (default, Jul  1 2016, 15:12:24) - [GCC 5.4.0 20160609]
pyOpenSSL : 16.1.0 (OpenSSL 1.0.2g  1 Mar 2016)
Platform  : Linux-4.4.0-43-generic-x86_64-with-Ubuntu-16.04-xenial


$ scrapy shell ftp://ftp.eu.metabrainz.org/pub/musicbrainz/data/fullexport/20161019-001816/MD5SUMS
2016-10-20 16:01:27 [scrapy] INFO: Scrapy 1.2.0 started (bot: scrapybot)
(...)
2016-10-20 16:01:27 [scrapy] INFO: Spider opened
Traceback (most recent call last):
File "/home/paul/.virtualenvs/scrapy12/bin/scrapy", line 11, in <module>
sys.exit(execute())
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/cmdline.py", line 142, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/cmdline.py", line 88, in _run_print_help
func(*a, **kw)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/cmdline.py", line 149, in _run_command
cmd.run(args, opts)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/commands/shell.py", line 71, in run
shell.start(url=url)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/shell.py", line 47, in start
self.fetch(url, spider)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/scrapy/shell.py", line 112, in fetch
reactor, self._schedule, request, spider)
File "/home/paul/.virtualenvs/scrapy12/local/lib/python2.7/site-packages/twisted/internet/threads.py", line 122, in blockingCallFromThread
result.raiseException()
File "<string>", line 2, in raiseException
KeyError: 'ftp_user'

# Fixed code
def download_request(self, request, spider):
    parsed_url = urlparse_cached(request)
    user = request.meta.get("ftp_user", self.default_user)
    password = request.meta.get("ftp_password", self.default_password)
    passive_mode = 1 if bool(request.meta.get("ftp_passive", self.passive_mode)) else 0
    creator = ClientCreator(reactor, FTPClient, user, password, passive=passive_mode)
    return creator.connectTCP(parsed_url.hostname, parsed_url.port or 21).addCallback(
        self.gotClient, request, unquote(parsed_url.path)
    )
# Buggy code
def add_options(self, parser):
    ScrapyCommand.add_options(self, parser)
    parser.add_option("--spider", dest="spider", help="use this spider")


# Traceback (AttributeError)
(py35) wingyiu@mbp101:~$scrapy view http://www.scrapy.org
2017-01-19 22:13:54 [scrapy.utils.log] INFO: Scrapy 1.3.0 started (bot: scrapybot)
2017-01-19 22:13:54 [scrapy.utils.log] INFO: Overridden settings: {}
Traceback (most recent call last):
File "/Users/user/venv/py35/bin/scrapy", line 11, in <module>
sys.exit(execute())
File "/Users/user/venv/py35/lib/python3.5/site-packages/scrapy/cmdline.py", line 142, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/Users/user/venv/py35/lib/python3.5/site-packages/scrapy/cmdline.py", line 88, in _run_print_help
func(*a, **kw)
File "/Users/user/venv/py35/lib/python3.5/site-packages/scrapy/cmdline.py", line 149, in _run_command
cmd.run(args, opts)
File "/Users/user/venv/py35/lib/python3.5/site-packages/scrapy/commands/fetch.py", line 58, in run
if not opts.no_redirect:
AttributeError: 'Values' object has no attribute 'no_redirect'

# Fixed code
def add_options(self, parser):
    super(Command, self).add_options(parser)
    parser.remove_option("--headers")
# Buggy code
def process_request_2(self, rp, request, spider):
    if rp is not None and not rp.can_fetch(self._useragent, request.url):
        logger.debug(
            "Forbidden by robots.txt: %(request)s",
            {"request": request},
            extra={"spider": spider},
        )
        raise IgnoreRequest()


# Traceback (KeyError)
2016-11-02 13:13:18 [scrapy] DEBUG: Crawled (200) <GET https://en.wikipedia.org/robots.txt> (referer: None)
2016-11-02 13:13:18 [py.warnings] WARNING: C:\Python27\lib\urllib.py:1303: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
return ''.join(map(quoter, s))

2016-11-02 13:13:18 [scrapy] ERROR: Error downloading <GET http://en.wikipedia.org/robots.txt>: u'\xd8'
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\twisted\internet\defer.py", line 587, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "C:\Python27\lib\site-packages\scrapy\downloadermiddlewares\robotstxt.py", line 97, in _parse_robots
rp.parse(body.splitlines())
File "C:\Python27\lib\robotparser.py", line 120, in parse
entry.rulelines.append(RuleLine(line[1], False))
File "C:\Python27\lib\robotparser.py", line 174, in __init__
self.path = urllib.quote(path)
File "C:\Python27\lib\urllib.py", line 1303, in quote
return ''.join(map(quoter, s))
KeyError: u'\xd8'

# Fixed code
def process_request_2(self, rp, request, spider):
    if rp is not None and not rp.can_fetch(to_native_str(self._useragent), request.url):
        logger.debug(
            "Forbidden by robots.txt: %(request)s",
            {"request": request},
            extra={"spider": spider},
        )
        raise IgnoreRequest()
# Buggy code
def _parse_robots(self, response, netloc):
    rp = robotparser.RobotFileParser(response.url)
    body = ""
    if hasattr(response, "text"):
        body = response.text
    else:  # last effort try
        try:
            body = response.body.decode("utf-8")
        except UnicodeDecodeError:
            # If we found garbage, disregard it:,
            # but keep the lookup cached (in self._parsers)
            # Running rp.parse() will set rp state from
            # 'disallow all' to 'allow any'.
            pass
    rp.parse(body.splitlines())

    rp_dfd = self._parsers[netloc]
    self._parsers[netloc] = rp
    rp_dfd.callback(rp)


# Traceback (KeyError)
2016-11-02 13:13:18 [scrapy] DEBUG: Crawled (200) <GET https://en.wikipedia.org/robots.txt> (referer: None)
2016-11-02 13:13:18 [py.warnings] WARNING: C:\Python27\lib\urllib.py:1303: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
return ''.join(map(quoter, s))

2016-11-02 13:13:18 [scrapy] ERROR: Error downloading <GET http://en.wikipedia.org/robots.txt>: u'\xd8'
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\twisted\internet\defer.py", line 587, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "C:\Python27\lib\site-packages\scrapy\downloadermiddlewares\robotstxt.py", line 97, in _parse_robots
rp.parse(body.splitlines())
File "C:\Python27\lib\robotparser.py", line 120, in parse
entry.rulelines.append(RuleLine(line[1], False))
File "C:\Python27\lib\robotparser.py", line 174, in __init__
self.path = urllib.quote(path)
File "C:\Python27\lib\urllib.py", line 1303, in quote
return ''.join(map(quoter, s))
KeyError: u'\xd8'

# Fixed code
def _parse_robots(self, response, netloc):
    rp = robotparser.RobotFileParser(response.url)
    body = ""
    if hasattr(response, "text"):
        body = response.text
    else:  # last effort try
        try:
            body = response.body.decode("utf-8")
        except UnicodeDecodeError:
            # If we found garbage, disregard it:,
            # but keep the lookup cached (in self._parsers)
            # Running rp.parse() will set rp state from
            # 'disallow all' to 'allow any'.
            pass
    # stdlib's robotparser expects native 'str' ;
    # with unicode input, non-ASCII encoded bytes decoding fails in Python2
    rp.parse(to_native_str(body).splitlines())

    rp_dfd = self._parsers[netloc]
    self._parsers[netloc] = rp
    rp_dfd.callback(rp)
# Buggy code
def _identityVerifyingInfoCallback(self, connection, where, ret):
    if where & SSL_CB_HANDSHAKE_START:
        _maybeSetHostNameIndication(connection, self._hostnameBytes)
    elif where & SSL_CB_HANDSHAKE_DONE:
        try:
            verifyHostname(connection, self._hostnameASCII)
        except VerificationError as e:
            logger.warning(
                'Remote certificate is not valid for hostname "{}"; {}'.format(
                    self._hostnameASCII, e
                )
            )


# Traceback (exceptions.ValueError)
2016-07-05 15:50:17 [twisted] CRITICAL: Error during info_callback
Traceback (most recent call last):
File "c:\python27\lib\site-packages\twisted\protocols\tls.py", line 421, in dataReceived
self._write(bytes)
File "c:\python27\lib\site-packages\twisted\protocols\tls.py", line 569, in _write
sent = self._tlsConnection.send(toSend)
File "c:\python27\lib\site-packages\OpenSSL\SSL.py", line 1270, in send
result = _lib.SSL_write(self._ssl, buf, len(buf))
File "c:\python27\lib\site-packages\OpenSSL\SSL.py", line 933, in wrapper
callback(Connection._reverse_mapping[ssl], where, return_code)
--- <exception caught here> ---
File "c:\python27\lib\site-packages\twisted\internet\_sslverify.py", line 1154, in infoCallback
return wrapped(connection, where, ret)
File "c:\python27\lib\site-packages\scrapy\core\downloader\tls.py", line 45, in _identityVerifyingInfoCallback
verifyHostname(connection, self._hostnameASCII)
File "c:\python27\lib\site-packages\service_identity\pyopenssl.py", line 45, in verify_hostname
obligatory_ids=[DNS_ID(hostname)],
File "c:\python27\lib\site-packages\service_identity\_common.py", line 245, in __init__
raise ValueError("Invalid DNS-ID.")
exceptions.ValueError: Invalid DNS-ID.

# Fixed code
def _identityVerifyingInfoCallback(self, connection, where, ret):
    if where & SSL_CB_HANDSHAKE_START:
        _maybeSetHostNameIndication(connection, self._hostnameBytes)
    elif where & SSL_CB_HANDSHAKE_DONE:
        try:
            verifyHostname(connection, self._hostnameASCII)
        except VerificationError as e:
            logger.warning(
                'Remote certificate is not valid for hostname "{}"; {}'.format(
                    self._hostnameASCII, e
                )
            )

        except ValueError as e:
            logger.warning(
                "Ignoring error while verifying certificate "
                'from host "{}" (exception: {})'.format(self._hostnameASCII, repr(e))
            )
# Buggy code
def from_content_disposition(self, content_disposition):
    try:
        filename = to_native_str(content_disposition).split(";")[1].split("=")[1]
        filename = filename.strip("\"'")
        return self.from_filename(filename)
    except IndexError:
        return Response


# Traceback (UnicodeDecodeError)
Traceback (most recent call last):
File "/Users/kmike/envs/dl/bin/scrapy", line 9, in <module>
load_entry_point('Scrapy', 'console_scripts', 'scrapy')()
File "/Users/kmike/svn/scrapy/scrapy/cmdline.py", line 142, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/Users/kmike/svn/scrapy/scrapy/cmdline.py", line 88, in _run_print_help
func(*a, **kw)
File "/Users/kmike/svn/scrapy/scrapy/cmdline.py", line 149, in _run_command
cmd.run(args, opts)
File "/Users/kmike/svn/scrapy/scrapy/commands/shell.py", line 71, in run
shell.start(url=url)
File "/Users/kmike/svn/scrapy/scrapy/shell.py", line 47, in start
self.fetch(url, spider)
File "/Users/kmike/svn/scrapy/scrapy/shell.py", line 112, in fetch
reactor, self._schedule, request, spider)
File "/Users/kmike/envs/dl/lib/python3.5/site-packages/Twisted-15.5.0-py3.5.egg/twisted/internet/threads.py", line 122, in blockingCallFromThread
result.raiseException()
File "/Users/kmike/envs/dl/lib/python3.5/site-packages/Twisted-15.5.0-py3.5.egg/twisted/python/failure.py", line 368, in raiseException
raise self.value.with_traceback(self.tb)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 25: invalid start byte

# Fixed code
def from_content_disposition(self, content_disposition):
    try:
        filename = (
            to_native_str(content_disposition, encoding="latin-1", errors="replace")
            .split(";")[1]
            .split("=")[1]
        )
        filename = filename.strip("\"'")
        return self.from_filename(filename)
    except IndexError:
        return Response
# Buggy code
def __init__(self, tag="a", attr="href", process=None, unique=False):
    self.scan_tag = tag if callable(tag) else lambda t: t == tag
    self.scan_attr = attr if callable(attr) else lambda a: a == attr
    self.process_attr = process if callable(process) else lambda v: v
    self.unique = unique

    self.links = []


# Traceback (test_retry_dns_error)
$ trial scrapy.tests.test_crawl.CrawlTestCase
scrapy.tests.test_crawl
CrawlTestCase
test_delay ...                                                         [OK]
test_engine_status ...                                                 [OK]
test_follow_all ...                                                  [FAIL]
test_referer_header ...                                                [OK]
test_retry_503 ...                                                     [OK]
test_retry_conn_aborted ...                                            [OK]
test_retry_conn_failed ...                                             [OK]
test_retry_conn_lost ...                                               [OK]
test_retry_dns_error ...                                               [OK]
test_start_requests_bug_before_yield ...                               [OK]
test_start_requests_bug_yielding ...                                   [OK]
test_start_requests_dupes ...                                          [OK]
test_start_requests_lazyness ...                                       [OK]
test_timeout_failure ...                                               [OK]
test_timeout_success ...                                               [OK]
test_unbounded_response ...                                            [OK]

===============================================================================
[FAIL]
Traceback (most recent call last):
File "/home/daniel/envs/scrapy/lib/python2.7/site-packages/twisted/internet/defer.py", line 1099, in _inlineCallbacks
result = g.send(result)
File "/home/daniel/src/scrapy/scrapy/tests/test_crawl.py", line 26, in test_follow_all
self.assertEqual(len(spider.urls_visited), 11)  # 10 + start_url
File "/home/daniel/envs/scrapy/lib/python2.7/site-packages/twisted/trial/_synctest.py", line 356, in assertEqual
% (msg, pformat(first), pformat(second)))
twisted.trial.unittest.FailTest: not equal:
a = 31
b = 11


scrapy.tests.test_crawl.CrawlTestCase.test_follow_all
-------------------------------------------------------------------------------
Ran 16 tests in 90.150s

FAILED (failures=1, successes=15)

$ trial scrapy.tests.test_crawl.CrawlTestCase.test_follow_all
scrapy.tests.test_crawl
CrawlTestCase
test_follow_all ...                                                    [OK]

-------------------------------------------------------------------------------
Ran 1 tests in 0.874s

PASSED (successes=1)

# Fixed code
def __init__(self, tag="a", attr="href", process=None, unique=False):
    self.scan_tag = tag if callable(tag) else lambda t: t == tag
    self.scan_attr = attr if callable(attr) else lambda a: a == attr
    self.process_attr = process if callable(process) else lambda v: v
    self.unique = unique
# Buggy code
def outgoing_response(self, request_id: Any, params: Any) -> None:
    if not self.settings.log_debug:
        return
    self.log(
        self.format_response(Direction.Outgoing, request_id),
        params,
        self.settings.log_payloads,
    )


# Traceback (ValueError)
Error handling server payload
Traceback (most recent call last):
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 201, in receive_payload
self.request_or_notification_handler(payload)
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 250, in request_or_notification_handler
request_id_int = int(request_id)
ValueError: invalid literal for int() with base 10: '32c845a7-9a86-4bf4-9d12-b4813fcfbca5'

# Fixed code
def outgoing_response(self, request_id: Any, params: Any) -> None:
    if not self.settings.log_debug:
        return
    self.log(
        self.format_response(">>>", request_id), params, self.settings.log_payloads
    )
# Buggy code
def outgoing_request(
    self, request_id: int, method: str, params: Any, blocking: bool
) -> None:
    if not self.settings.log_debug:
        return
    direction = Direction.OutgoingBlocking if blocking else Direction.Outgoing
    self.log(
        self.format_request(direction, method, request_id),
        params,
        self.settings.log_payloads,
    )


# Traceback (ValueError)
Error handling server payload
Traceback (most recent call last):
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 201, in receive_payload
self.request_or_notification_handler(payload)
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 250, in request_or_notification_handler
request_id_int = int(request_id)
ValueError: invalid literal for int() with base 10: '32c845a7-9a86-4bf4-9d12-b4813fcfbca5'

# Fixed code
def outgoing_request(
    self, request_id: int, method: str, params: Any, blocking: bool
) -> None:
    if not self.settings.log_debug:
        return
    direction = "==>" if blocking else "-->"
    self.log(
        self.format_request(direction, method, request_id),
        params,
        self.settings.log_payloads,
    )
# Buggy code
def outgoing_notification(self, method: str, params: Any) -> None:
    if not self.settings.log_debug:
        return
    # Do not log the payloads if any of these conditions occur because the payloads might contain the entire
    # content of the view.
    log_payload = (
        self.settings.log_payloads
        and method != "textDocument/didChange"
        and method != "textDocument/didOpen"
    )
    if (
        log_payload
        and method == "textDocument/didSave"
        and isinstance(params, dict)
        and "text" in params
    ):
        log_payload = False
    self.log(self.format_notification(Direction.Outgoing, method), params, log_payload)


# Traceback (ValueError)
Error handling server payload
Traceback (most recent call last):
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 201, in receive_payload
self.request_or_notification_handler(payload)
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 250, in request_or_notification_handler
request_id_int = int(request_id)
ValueError: invalid literal for int() with base 10: '32c845a7-9a86-4bf4-9d12-b4813fcfbca5'

# Fixed code
def outgoing_notification(self, method: str, params: Any) -> None:
    if not self.settings.log_debug:
        return
    # Do not log the payloads if any of these conditions occur because the payloads might contain the entire
    # content of the view.
    log_payload = (
        self.settings.log_payloads
        and method != "textDocument/didChange"
        and method != "textDocument/didOpen"
    )
    if (
        log_payload
        and method == "textDocument/didSave"
        and isinstance(params, dict)
        and "text" in params
    ):
        log_payload = False
    self.log(self.format_notification(" ->", method), params, log_payload)
# Buggy code
def incoming_response(self, request_id: int, params: Any) -> None:
    if not self.settings.log_debug:
        return
    self.log(
        self.format_response(Direction.Incoming, request_id),
        params,
        self.settings.log_payloads,
    )


# Traceback (ValueError)
Error handling server payload
Traceback (most recent call last):
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 201, in receive_payload
self.request_or_notification_handler(payload)
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 250, in request_or_notification_handler
request_id_int = int(request_id)
ValueError: invalid literal for int() with base 10: '32c845a7-9a86-4bf4-9d12-b4813fcfbca5'

# Fixed code
def incoming_response(self, request_id: int, params: Any) -> None:
    if not self.settings.log_debug:
        return
    self.log(
        self.format_response("<<<", request_id), params, self.settings.log_payloads
    )
# Buggy code
def incoming_request(
    self, request_id: Any, method: str, params: Any, unhandled: bool
) -> None:
    if not self.settings.log_debug:
        return
    direction = "unhandled" if unhandled else Direction.Incoming
    self.log(
        self.format_request(direction, method, request_id),
        params,
        self.settings.log_payloads,
    )


# Traceback (ValueError)
Error handling server payload
Traceback (most recent call last):
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 201, in receive_payload
self.request_or_notification_handler(payload)
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 250, in request_or_notification_handler
request_id_int = int(request_id)
ValueError: invalid literal for int() with base 10: '32c845a7-9a86-4bf4-9d12-b4813fcfbca5'

# Fixed code
def incoming_request(
    self, request_id: Any, method: str, params: Any, unhandled: bool
) -> None:
    if not self.settings.log_debug:
        return
    direction = "<??" if unhandled else "<--"
    self.log(
        self.format_request(direction, method, request_id),
        params,
        self.settings.log_payloads,
    )
# Buggy code
def incoming_notification(self, method: str, params: Any, unhandled: bool) -> None:
    if not self.settings.log_debug or method == "window/logMessage":
        return
    direction = "unhandled" if unhandled else Direction.Incoming
    self.log(
        self.format_notification(direction, method), params, self.settings.log_payloads
    )


# Traceback (ValueError)
Error handling server payload
Traceback (most recent call last):
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 201, in receive_payload
self.request_or_notification_handler(payload)
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 250, in request_or_notification_handler
request_id_int = int(request_id)
ValueError: invalid literal for int() with base 10: '32c845a7-9a86-4bf4-9d12-b4813fcfbca5'

# Fixed code
def incoming_notification(self, method: str, params: Any, unhandled: bool) -> None:
    if not self.settings.log_debug or method == "window/logMessage":
        return
    direction = "<? " if unhandled else "<- "
    self.log(
        self.format_notification(direction, method), params, self.settings.log_payloads
    )
# Buggy code
def request_or_notification_handler(self, payload: Mapping[str, Any]) -> None:
    method = payload["method"]  # type: str
    params = payload.get("params")
    # Server request IDs can be either a string or an int.
    request_id = payload.get("id")
    if request_id is not None:
        self.handle(
            request_id,
            method,
            params,
            "request",
            self._request_handlers,
            lambda a, b, c: self.logger.incoming_request(request_id, a, b, c),
        )
    else:
        self.handle(
            None,
            method,
            params,
            "notification",
            self._notification_handlers,
            self.logger.incoming_notification,
        )


# Traceback (ValueError)
Error handling server payload
Traceback (most recent call last):
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 201, in receive_payload
self.request_or_notification_handler(payload)
File "C:\Users\Janos\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/rpc.py", line 250, in request_or_notification_handler
request_id_int = int(request_id)
ValueError: invalid literal for int() with base 10: '32c845a7-9a86-4bf4-9d12-b4813fcfbca5'

# Fixed code
def request_or_notification_handler(self, payload: Mapping[str, Any]) -> None:
    method = payload["method"]  # type: str
    params = payload.get("params")
    # Server request IDs can be either a string or an int.
    request_id = payload.get("id")
    if request_id is not None:
        self.handle(
            request_id,
            method,
            params,
            "request",
            self._request_handlers,
            lambda *args: self.logger.incoming_request(request_id, *args),
        )
    else:
        self.handle(
            None,
            method,
            params,
            "notification",
            self._notification_handlers,
            self.logger.incoming_notification,
        )
# Buggy code
def __init__(self, view: sublime.View) -> None:
    super().__init__(view)
    self.reflist = []  # type: List[List[str]]


# Traceback (ValueError)
LSP:  --> textDocument/references
LSP:      [{'uri': 'file:///D:/Amjad/rls-vscode/src/extension.ts', 'range': {'end': {'line': 25, 'character': 20}, 'start': {'line': 25, 'character': 9}}}, {'uri': 'file:///D:/Amjad/rls-vscode/src/extension.ts', 'range': {'end': {'line': 434, 'character': 25}, 'start': {'line': 434, 'character': 14}}}, {'uri': 'file:///D:/Amjad/rls-vscode/src/rustup.ts', 'range': {'end': {'line': 67, 'character': 33}, 'start': {'line': 67, 'character': 22}}}]
Error handling server payload
Traceback (most recent call last):
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\rpc.py", line 150, in receive_payload
self.response_handler(payload)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\rpc.py", line 169, in response_handler
handler(response["result"])
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 45, in <lambda>
request, lambda response: self.handle_response(response, pos))
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 64, in handle_response
formatted_references = self._get_formatted_references(response, base_dir)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 142, in _get_formatted_references
grouped_references = self._group_references_by_file(references, base_dir)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 150, in _group_references_by_file
relative_file_path = os.path.relpath(file_path, base_dir)
File "./python3.3/ntpath.py", line 564, in relpath
ValueError: path is on mount 'D:', start on mount 'C:'

# Fixed code
def __init__(self, view: sublime.View) -> None:
    super().__init__(view)
    self.reflist = []  # type: List[List[str]]
    self.word_region = None  # type: Optional[sublime.Region]
    self.word = ""
    self.base_dir = None  # type: Optional[str]
# Buggy code
def on_ref_choice(self, base_dir: "Optional[str]", index: int) -> None:
    window = self.view.window()
    if index != -1:
        window.open_file(
            self.get_selected_file_path(base_dir, index), sublime.ENCODED_POSITION
        )


# Traceback (ValueError)
LSP:  --> textDocument/references
LSP:      [{'uri': 'file:///D:/Amjad/rls-vscode/src/extension.ts', 'range': {'end': {'line': 25, 'character': 20}, 'start': {'line': 25, 'character': 9}}}, {'uri': 'file:///D:/Amjad/rls-vscode/src/extension.ts', 'range': {'end': {'line': 434, 'character': 25}, 'start': {'line': 434, 'character': 14}}}, {'uri': 'file:///D:/Amjad/rls-vscode/src/rustup.ts', 'range': {'end': {'line': 67, 'character': 33}, 'start': {'line': 67, 'character': 22}}}]
Error handling server payload
Traceback (most recent call last):
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\rpc.py", line 150, in receive_payload
self.response_handler(payload)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\rpc.py", line 169, in response_handler
handler(response["result"])
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 45, in <lambda>
request, lambda response: self.handle_response(response, pos))
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 64, in handle_response
formatted_references = self._get_formatted_references(response, base_dir)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 142, in _get_formatted_references
grouped_references = self._group_references_by_file(references, base_dir)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 150, in _group_references_by_file
relative_file_path = os.path.relpath(file_path, base_dir)
File "./python3.3/ntpath.py", line 564, in relpath
ValueError: path is on mount 'D:', start on mount 'C:'

# Fixed code
def on_ref_choice(self, index: int) -> None:
    self.open_ref_index(index)
# Buggy code
def on_ref_highlight(self, base_dir: "Optional[str]", index: int) -> None:
    window = self.view.window()
    if index != -1:
        window.open_file(
            self.get_selected_file_path(base_dir, index),
            sublime.ENCODED_POSITION | sublime.TRANSIENT,
        )


# Traceback (ValueError)
LSP:  --> textDocument/references
LSP:      [{'uri': 'file:///D:/Amjad/rls-vscode/src/extension.ts', 'range': {'end': {'line': 25, 'character': 20}, 'start': {'line': 25, 'character': 9}}}, {'uri': 'file:///D:/Amjad/rls-vscode/src/extension.ts', 'range': {'end': {'line': 434, 'character': 25}, 'start': {'line': 434, 'character': 14}}}, {'uri': 'file:///D:/Amjad/rls-vscode/src/rustup.ts', 'range': {'end': {'line': 67, 'character': 33}, 'start': {'line': 67, 'character': 22}}}]
Error handling server payload
Traceback (most recent call last):
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\rpc.py", line 150, in receive_payload
self.response_handler(payload)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\rpc.py", line 169, in response_handler
handler(response["result"])
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 45, in <lambda>
request, lambda response: self.handle_response(response, pos))
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 64, in handle_response
formatted_references = self._get_formatted_references(response, base_dir)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 142, in _get_formatted_references
grouped_references = self._group_references_by_file(references, base_dir)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 150, in _group_references_by_file
relative_file_path = os.path.relpath(file_path, base_dir)
File "./python3.3/ntpath.py", line 564, in relpath
ValueError: path is on mount 'D:', start on mount 'C:'

# Fixed code
def on_ref_highlight(self, index: int) -> None:
    self.open_ref_index(index, transient=True)
# Buggy code
def get_selected_file_path(self, base_dir: "Optional[str]", index: int) -> str:
    file_path = self.reflist[index][0]
    if base_dir:
        file_path = os.path.join(base_dir, file_path)
    return file_path


# Traceback (ValueError)
LSP:  --> textDocument/references
LSP:      [{'uri': 'file:///D:/Amjad/rls-vscode/src/extension.ts', 'range': {'end': {'line': 25, 'character': 20}, 'start': {'line': 25, 'character': 9}}}, {'uri': 'file:///D:/Amjad/rls-vscode/src/extension.ts', 'range': {'end': {'line': 434, 'character': 25}, 'start': {'line': 434, 'character': 14}}}, {'uri': 'file:///D:/Amjad/rls-vscode/src/rustup.ts', 'range': {'end': {'line': 67, 'character': 33}, 'start': {'line': 67, 'character': 22}}}]
Error handling server payload
Traceback (most recent call last):
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\rpc.py", line 150, in receive_payload
self.response_handler(payload)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\rpc.py", line 169, in response_handler
handler(response["result"])
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 45, in <lambda>
request, lambda response: self.handle_response(response, pos))
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 64, in handle_response
formatted_references = self._get_formatted_references(response, base_dir)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 142, in _get_formatted_references
grouped_references = self._group_references_by_file(references, base_dir)
File "C:\Users\Lehdhili\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\references.py", line 150, in _group_references_by_file
relative_file_path = os.path.relpath(file_path, base_dir)
File "./python3.3/ntpath.py", line 564, in relpath
ValueError: path is on mount 'D:', start on mount 'C:'

# Fixed code
def get_selected_file_path(self, index: int) -> str:
    return self.get_full_path(self.reflist[index][0])
# Buggy code
def open_and_apply_edits(self, path, file_changes):
    view = self.window.open_file(path)
    if view:
        if view.is_loading():
            # TODO: wait for event instead.
            sublime.set_timeout_async(
                lambda: view.run_command(
                    "lsp_apply_document_edit", {"changes": file_changes}
                ),
                500,
            )
        else:
            view.run_command(
                "lsp_apply_document_edit",
                {"changes": file_changes, "show_status": False},
            )
    else:
        debug("view not found to apply", path, file_changes)


# Traceback (TypeError)
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 1082, in run_
return self.run(edit, **args)
TypeError: run() got an unexpected keyword argument 'show_status'

# Fixed code
def open_and_apply_edits(self, path, file_changes):
    view = self.window.open_file(path)
    if view:
        if view.is_loading():
            # TODO: wait for event instead.
            sublime.set_timeout_async(
                lambda: view.run_command(
                    "lsp_apply_document_edit", {"changes": file_changes}
                ),
                500,
            )
        else:
            view.run_command("lsp_apply_document_edit", {"changes": file_changes})
    else:
        debug("view not found to apply", path, file_changes)
# Buggy code
def is_applicable(cls, settings):
    syntax = settings.get("syntax")
    if syntax is not None:
        return is_supported_syntax(syntax, client_configs.all)
    else:
        return False


# Traceback (TypeError)
Traceback (most recent call last):
File "F:\SublimeText\sublime_plugin.py", line 298, in on_api_ready
plc()
File "F:\SublimeText\Data\Packages\LSP\boot.py", line 30, in plugin_loaded
startup()
File "F:\SublimeText\Data\Packages\LSP\plugin\core\main.py", line 25, in startup
start_active_window()
File "F:\SublimeText\Data\Packages\LSP\plugin\core\main.py", line 44, in start_active_window
windows.lookup(window).start_active_views()
File "F:\SublimeText\Data\Packages\LSP\plugin\core\windows.py", line 336, in start_active_views
self._initialize_on_open(view)
File "F:\SublimeText\Data\Packages\LSP\plugin\core\windows.py", line 348, in _initialize_on_open
self._configs.syntax_configs(view))
File "F:\SublimeText\Data\Packages\LSP\plugin\core\configurations.py", line 120, in syntax_configs
return list(filter(lambda c: config_supports_syntax(c, syntax) and c.enabled, self.all))
File "F:\SublimeText\Data\Packages\LSP\plugin\core\configurations.py", line 120, in <lambda>
return list(filter(lambda c: config_supports_syntax(c, syntax) and c.enabled, self.all))
File "F:\SublimeText\Data\Packages\LSP\plugin\core\types.py", line 81, in config_supports_syntax
if re.search(r'|'.join(r'\b%s\b' % re.escape(s) for s in language.syntaxes), syntax, re.IGNORECASE):
File "./python3.3/re.py", line 161, in search
TypeError: expected string or buffer

# Fixed code
def is_applicable(cls, settings):
    syntax = settings.get("syntax")
    return is_supported_syntax(syntax) if syntax else False