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