Page MenuHomePhabricator

editarticle uses deprecated optparser
Closed, ResolvedPublic


optparser was deprecated in py 2.7

It is used by

Version: core-(2.0)
Severity: trivial

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 (????).

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

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

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

The GCI task reads

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

Should that not be "replaced by handleArgs"?

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 ( 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


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

jayvdb claimed this task.

The build with this change merged was successful.

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

jayvdb set Security to None.
jayvdb removed a subscriber: Unknown Object (????).