Page MenuHomePhabricator

Insufficient polymorphism implementation of specialbots EditReplacement class
Open, HighPublic

Description

bot_choice.Option is derived by subclasses which sometimes overwrites stop properties and gives always False for example.

But specialbots.EditReplacement is derived from ChoiceException and UnhandledAnswer which sets a stop attribute.

ChoiceException is derived from StandardOption and Exception.
StandardOption is derived from Option and has a stop property which has to be set by a setter property. Otherwise it will fail.

UnhandledAnswer is an Exception which also sets a stop attribute.

See https://gerrit.wikimedia.org/r/#/c/pywikibot/core/+/321576/

Sample:

>>> import pwb, pywikibot as py
>>> from pywikibot.specialbots import EditReplacement
>>> raise EditReplacement

Traceback (most recent call last):
  File "pywikibot\specialbots.py", line 495, in __init__
    self.stop = True
AttributeError: can't set attribute
>>>

Event Timeline

Xqt triaged this task as High priority.
Xqt removed Xqt as the assignee of this task.Jan 1 2019, 6:59 PM

Change 482279 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] Fix polymorphism implementation of bot_choice.Option

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

Aklapper removed Xqt as the assignee of this task.Jul 2 2021, 5:14 AM

Removing task assignee due to inactivity, as this open task has been assigned for more than two years (see emails sent to assignee on May26 and Jun17, and T270544). Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be very welcome!

(See https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator.)