Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[http] fix parsing link header #1924

Merged
merged 2 commits into from
Jun 20, 2023
Merged

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Jun 18, 2023

Closes #1898.

I could not reproduce the error AttributeError: module 'urllib' has no attribute 'error' but I have attempted to patch it anyway by changing the import from urllib to urllib.error.

This commit uses requests. I am not sure if I did the import of requests.utils properly. I do import requests.utils
but I see there's some reason not to mix import and vd.importExternal, and I see that it is done using importExternal in

requests = vd.importExternal('requests')

Also I know we just got rid of most uses of requests because of a bug they refuse to fix. I am only using one simple function from it. But maybe we'd rather not use requests at all?

In any case, I have tested that this commit fixes pagination by loading vd https://api.github.com/repos/django/django/pulls with options.http_max_next = 2 and confirming that I see 3*30 = 90 rows.

break

vd.status(f'fetching next page from {src}')
response = requests.get(src, stream=True, **vd.options.getall('http_req_'))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this is weird, were we still trying to use the requests library without importing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there had previously been two lines with requests.get(), but only the first one had been changed to use urllib.request.urlopen().

@saulpw
Copy link
Owner

saulpw commented Jun 18, 2023

You're right, at this point I would prefer not to use requests at all. Can we copy or inline the function you're using?

@midichef midichef marked this pull request as ready for review June 19, 2023 06:28
Copy link
Owner

@saulpw saulpw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @midichef, looks good to me.

@anjakefala anjakefala merged commit c1fef18 into saulpw:develop Jun 20, 2023
13 checks passed
@midichef midichef deleted the http_parse branch June 22, 2023 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[urllib imports] Multiple urllib imports are missing
3 participants