Page MenuHomePhabricator

Solve inconsistency between requests and comms
Closed, ResolvedPublic

Description

pywikibot.comms.http.fetch:

  • raw - content of the response (file content), in bytes
  • content - content of the response (file content), in unicode

requests.request:

  • content - content of the response (file content), in bytes
  • text - content of the response (file content), in unicode

Event Timeline

This inconsistency caused T159645, T155509 and T166617 in reflinks.py

This comment was removed by Dvorapa.

I don't see the point. requests shouldn't be used directly but http methods should be used as the lowest layer instead.

@Xqt Short answer: This inconsistency caused this mistaken error

Long answer: Follow me: If I am used to use requests in some other project, I am used to its syntax. But when I use pywikibot.comms.http.fetch method, it has got these two method names swapped and I can be easily confused. Which can finally cause that I use wrong method and get a response in bytes instead of textual and the whole script stops working (as it was in reflinks.py)

Xqt triaged this task as Low priority.Jan 31 2018, 3:23 PM

Change 421282 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] threadedhttp.py: Deprecate HttpRequest.content in favour of text

https://gerrit.wikimedia.org/r/421282

Change 421282 merged by jenkins-bot:
[pywikibot/core@master] threadedhttp.py: Deprecate HttpRequest.content in favour of text

https://gerrit.wikimedia.org/r/421282