Skip to content

FronteraScheduler._request_is_redirected looks suspicious #243

@kmike

Description

@kmike

See

def _request_is_redirected(self, request):
:

    def _request_is_redirected(self, request):
        return request.meta.get(b'redirect_times', 0) > 0

^^ in Python 2 this is the same as checking for 'redirect_times' key, but in Python 3 b'redirect_times' != 'redirect_times', so this condition won't work with Scrapy's redirect middlewares in Python 3.

Tests are not catching that because in scheduler tests scrapy.Request objects are created with bytes keys in meta:

rr1 = Request('http://www.example.com', meta={b'redirect_times': 1})
. Scrapy don't create such responses: it always use native strings (str, i.e. bytes in Python 2 and uncode in Python 3) as meta keys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions