Page MenuHomePhabricator

Implement 'mark for deletion' for ItemPage
Open, LowPublic

Description

Currently, this throws an unclear error message

Can't delete [[en:Item:Q112]]; do you want to mark it for deletion instead? ([y]es, [N]o, [a]ll): y
WARNING: /usr/lib/python3/dist-packages/urllib3/connectionpool.py:732: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html (This warning will only appear once by default.)
Traceback (most recent call last):
  File "repo.py", line 11, in <module>
    repoitem.delete(reason, prompt=False)
  File "/home/till/Documents/Masterarbeit/TillsWiki/pywikibot/core/pywikibot/tools/__init__.py", line 1368, in wrapper
    return obj(*__args, **__kw)
  File "/home/till/Documents/Masterarbeit/TillsWiki/pywikibot/core/pywikibot/page.py", line 1780, in delete
    self.text = template + self.text
TypeError: Can't convert 'dict' object to str implicitly
<class 'TypeError'>

because self.text (i.e. the page contents) is a dictionary.

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Zppix, Aklapper. · View Herald TranscriptMay 6 2016, 10:51 AM
Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptMay 19 2016, 2:22 PM

@valhallasw would you be so kind as to explain the steps to reproduce the problem ? From what https://phabricator.wikimedia.org/diffusion/PWBC/browse/master/pywikibot/page.py reads, it is unclear when self.text can become something that's not a string. Thanks :-)

I think this issue may have solved itself (sort of):

valhallasw@maeglin:pywikibot-core$ python pwb.py shell
Welcome to the Pywikibot interactive shell!
>>> from pywikibot import ItemPage
>>> from pywikibot import Site
>>> p = pywikibot.ItemPage(pywikibot.Site('test', 'wikidata'), 'Q12848')
>>> p.delete()
Deleting [[wikidata:test:Q12848]].
Please enter a reason for the deletion: test
Can't delete [[wikidata:test:Q12848]]; do you want to mark it for deletion instead? ([y]es, [N]o, [a]ll): y
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/samba/src/pywikibot-core/pywikibot/tools/__init__.py", line 1417, in wrapper
    return obj(*__args, **__kw)
  File "/home/samba/src/pywikibot-core/pywikibot/page.py", line 1839, in delete
    self.text = template + self.text
TypeError: coercing to Unicode: need string or buffer, dict found

The correct result should be a {{delete}} template added on https://test.wikidata.org/w/index.php?title=Talk:Q12848 (as it can't be added on the item page itself)

Note that trying to delete-tag a non-existing item page gives a different error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/samba/src/pywikibot-core/pywikibot/tools/__init__.py", line 1417, in wrapper
    return obj(*__args, **__kw)
  File "/home/samba/src/pywikibot-core/pywikibot/page.py", line 1840, in delete
    return self.save(summary=reason)
  File "/home/samba/src/pywikibot-core/pywikibot/tools/__init__.py", line 1417, in wrapper
    return obj(*__args, **__kw)
  File "/home/samba/src/pywikibot-core/pywikibot/page.py", line 1208, in save
    cc=apply_cosmetic_changes, quiet=quiet, **kwargs)
  File "/home/samba/src/pywikibot-core/pywikibot/page.py", line 1234, in _save
    raise pywikibot.OtherPageSaveError(self, err)
OtherPageSaveError: Edit to page [[wikidata:test:Q1]] failed:
unknownerror: Unknown error: "wikibase-no-direct-editing" [help:See https://test.wikidata.org/w/api.php for API usage]

which should really throw a PageNotExists exception instead.

@JameerBabu: This issue has been assigned to you a while ago.
Could you please share a status update? Are you still working (or still plan to work) on this issue? Is there anything that others could help with? If you do not plan to work on this issue anymore, please remove yourself as assignee (via Add Action...Assign / Claim in the dropdown menu) so others could work on it. Thanks a lot!

Xqt removed JameerBabu as the assignee of this task.May 14 2018, 11:30 AM
Xqt triaged this task as Low priority.
Xqt added a subscriber: JameerBabu.

Change 434101 had a related patch set uploaded (by Framawiki; owner: Framawiki):
[pywikibot/core@master] [bugfix] Handle 'mark for deletion' of ItemPage.delete()

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

Xqt closed this task as Resolved.May 20 2018, 3:14 PM

Change 434101 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] Handle 'mark for deletion' of ItemPage.delete()

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

For reference, I had already made an abuse filter in 2017 to prevent this behavior on Wikidata. Since the beginning of Wikidata, the only standard to request deleting an item is filing one on Wikidata:Requests for deletions.

Framawiki reopened this task as Open.Jun 7 2018, 5:48 PM

Oh, thanks for the note @matej_suchanek. I thought adding the template to the talk page was the best way to implement a bot's deletion request. Can we imagine an exception/other process for bots ?
Because implementing requests on a unique page seems difficult. Are you sure Wikidata:Requests for deletions can be filled by a program? I mean I can't see dozens of open sections per bot on this page. And creating bulk requests in a unique section will be hard to implement without saving an edit for each item.

Framawiki removed Framawiki as the assignee of this task.Jun 7 2018, 5:48 PM
Framawiki added a subscriber: Framawiki.