Wikimedia

Pywikibot: Update BaseSite.urlEncode and create tests

See https://phabricator.wikimedia.org/T85321 for more info.

The method BaseSite.urlEncode from pywikibot-compat was copied to pywikibot-core as deprecated, and core uses urlencode as its implementation. In the compat , BaseSite.urlEncode moved wpEditToken to the last arg as recommended by the API documentation, and it did utf8 encoding. POST parameter encoding in core is now performed mostly in pywikibot.data.api.Request. This class does encoding properly, but does not re-order the parameters. To fix this, any parameter named '*token' should be moved to the end.

The deprecated BaseSite.urlEncode in core also needs to be updated so it is backwards compatible.

Tests need to be created to verify that pywikibot.data.api.Request and BaseSite.urlEncode re-order parameters, and very basic tests are needed to verify that BaseSite.urlEncode encodes the parameters correctly.

Pywikibot is a Python-based framework to write bots for MediaWiki. See https://www.mediawiki.org/wiki/Manual:Pywikibot for more info. Patches can be submitted via Gerrit (you need a MediaWiki.org account). See https://www.mediawiki.org/wiki/Manual:Pywikibot/Gerrit. After you have successfully claimed this task on this site please do use the task in Phabricator for communication instead. This allows more PWB developers to be reached! General dev questions can be asked on https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l and the #pywikibot IRC channel (see https://www.mediawiki.org/wiki/MediaWiki_on_IRC ).

Task tags

  • python
  • pywikibot

Students who completed this task

murfel

Task type

  • code Code
  • done_all Quality Assurance
close

2015