Last modified: 2014-06-01 15:09:25 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T67971, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 65971 - saving a page with empty text should be allowed with force flag
saving a page with empty text should be allowed with force flag
Status: RESOLVED FIXED
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All All
: Unprioritized normal
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-05-31 10:30 UTC by Ian Kelling
Modified: 2014-06-01 15:09 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Ian Kelling 2014-05-31 10:30:28 UTC
http://lists.wikimedia.org/pipermail/pywikipedia-l/2014-May/008740.html

There is a force flag, in the code, but it is not used to allow saving empty pages. It should be. Probably an easy fix along with this is that the correct exception is caught in Page._save and not re-raised - instead, a different
Exception is raised, which makes it harder to debug the code.

Here is an example script, and the error when running it

import pywikibot
site = pywikibot.Site()
page = pywikibot.Page(site, "MediaWiki:Lastmodifiedat")
page.text = ""
page.save()

Logging in to ianwiki:en as Ian Kelling
Traceback (most recent call last):
  File "pwb.py", line 143, in <module>
    run_python_file(fn, argv, argvu)
  File "pwb.py", line 67, in run_python_file
    exec(compile(source, filename, "exec"), main_mod.__dict__)
  File "scripts/iansetup.py", line 5, in <module>
    page.save()
  File "/a/opt/pywikibot/pywikibot/page.py", line 858, in save
    **kwargs)
  File "/a/opt/pywikibot/pywikibot/page.py", line 884, in _save
    raise pywikibot.PageNotSaved("%s: %s" % (link, err))
pywikibot.exceptions.PageNotSaved
CRITICAL: Waiting for 1 network thread(s) to finish. Press ctrl-c to abort
<class 'pywikibot.exceptions.PageNotSaved'>


The cause is in site.py, in def editpage, line 2699:

        if not text:
            raise Error("editpage: no text to be saved")
Comment 1 xqt 2014-05-31 10:37:00 UTC
Isn't this bug already solved with https://gerrit.wikimedia.org/r/#/c/135747/
Comment 2 Ian Kelling 2014-06-01 15:09:25 UTC
(In reply to xqt from comment #1)
> Isn't this bug already solved with https://gerrit.wikimedia.org/r/#/c/135747/

Yes, except for the error not propogating right, which can go into a different bug. I wasn't aware of that patch.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links