Page MenuHomePhabricator

editarticle uses deprecated optparser
Closed, ResolvedPublic

Description

optparser was deprecated in py 2.7
https://docs.python.org/2/library/argparse.html#module-argparse

It is used by editarticle.py


Version: core-(2.0)
Severity: trivial

Details

Reference
bz68617
Related Gerrit Patches:

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:37 AM
bzimport set Reference to bz68617.
bzimport added a subscriber: Unknown Object (????).
jayvdb created this task.Jul 26 2014, 3:02 PM
jayvdb added a comment.Nov 9 2014, 8:52 PM

"Deprecated since version 3.2: The optparse module is deprecated and will not be developed further; development will continue with the argparse module."

https://docs.python.org/3/library/optparse.html

Would that be a task suitable for Google Code-in and would somebody be willing to mentor a student? If so, feel free to add to https://www.mediawiki.org/wiki/Google_Code-in_2014#Proposed_tasks

That was my intention with marking it as easy. Added it to the proposed tasks.

The GCI task reads

The Pywikibot script named "editarticle.py" uses optparse which is deprecated in Python 3.2, this should be replaced by argparse

Should that not be "replaced by handleArgs"?

XZise added a comment.Dec 1 2014, 9:09 PM

No not really: handleArgs (or how it's now called handle_args) is already called (in line 46), but this request is about parsing the script specific parameters. And there are several ways to do that. Currently most scripts are doing it manually by iterating through the entries and then “doing it's stuff” but this is using optparse.

Now depending on how fast the argparse patch (https://gerrit.wikimedia.org/r/156089/) is going to be imported it would be better to just change the optparse into argparse. That is relatively easy and with that linked patch the adjustments are minimal.

Change 176747 had a related patch set uploaded (by Mloc-gci):
editarticle: move from optparse to argparse

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

Patch-For-Review

Change 176747 merged by jenkins-bot:
editarticle: move from optparse to argparse

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

jayvdb moved this task from Backlog to Needs Review on the Pywikibot board.Dec 3 2014, 7:28 AM
jayvdb closed this task as Resolved.Dec 3 2014, 8:03 AM
jayvdb claimed this task.

The build with this change merged was successful.

https://travis-ci.org/wikimedia/pywikibot-core/builds/42813041

This script could now be used as an example implementation for T76429.

jayvdb set Security to None.
jayvdb removed a subscriber: Unknown Object (????).
jayvdb moved this task from Backlog to pywikibot on the Google-Code-in-2014 board.Dec 7 2014, 2:11 AM
jayvdb reassigned this task from jayvdb to Mloc-gci.Jan 15 2015, 1:25 AM