Page MenuHomePhabricator

newitem.py -touch crashes on locked pages
Closed, ResolvedPublic

Description

pwb.py newitem -file:aa.txt -lang:cs -touch

...

[[cs:Šablona:Anontools]] already has an item: [[wikidata:Q6023401]].
Doing a null edit on the page.
WARNING: API error protectedpage: The "editprotected" right is required to edit this page
ERROR: Page [[cs:Šablona:Anontools]] is locked.
Traceback (most recent call last):
  File "I:\pwb\pywikibot\bot.py", line 1948, in run
    self.treat(page, item)
  File ".\scripts\newitem.py", line 71, in treat
    page.put(page.text)
  File "I:\pwb\pywikibot\tools\__init__.py", line 1447, in wrapper
    return obj(*__args, **__kw)
  File "I:\pwb\pywikibot\page.py", line 1292, in put
    **kwargs)
  File "I:\pwb\pywikibot\tools\__init__.py", line 1447, in wrapper
    return obj(*__args, **__kw)
  File "I:\pwb\pywikibot\page.py", line 1209, in save
    cc=apply_cosmetic_changes, quiet=quiet, **kwargs)
  File "I:\pwb\pywikibot\page.py", line 1234, in _save
    raise err
LockedPage: Page [[cs:Ĺ ablona:Anontools]] is locked.

Event Timeline

Ok, and what do You think, should be expected behaviour here?

Ok, and what do You think, should be expected behaviour here?

Expected is skipping page rather than crash

When touch.py finds locked page, simply skips:

...
Page [[Šablona:Colosseum]] saved
WARNING: API error protectedpage: The "editprotected" right is required to edit this page
ERROR: Page [[Šablona:Commons]] is locked.
Page [[Šablona:Commons/doc]] saved
Page [[Šablona:Commonscat]] saved
Page [[Šablona:Commonscat/doc]] saved
...

Change 327740 had a related patch set uploaded (by Magul):
newitem.py doesn't crash on LockedPage

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

@Dalba , @Xqt could check this review? There is a question about 79-characters limitation - do we want to always stick to it or do we aproach this limitation in more liberal way?

I usually recommend keeping lines below 80 characters, but only for those lines that are newly added. Older lines are usually kept unchanged which I assume helps when using git blame or searching the git log for specific change.

But personally I feel much more comfortable with the 80 characters line limit and would vote to merge changes like https://gerrit.wikimedia.org/r/#/c/287412/ .

I usually recommend keeping lines below 80 characters, but only for those lines that are newly added. Older lines are usually kept unchanged which I assume helps when using git blame or searching the git log for specific change.

But personally I feel much more comfortable with the 80 characters line limit and would vote to merge changes like https://gerrit.wikimedia.org/r/#/c/287412/ .

I'm happy to merge as is. Consistently applying the 80 char limit trumps the minor aesthetic loss in this particular case.
One work-around would be to go for something like:

self.pageAgeBefore = self.repo.getcurrenttime() - \
                     timedelta(days=self.pageAge)

which is slightly clearer but has it's own aesthetic losses.

I'm happy to merge as is. Consistently applying the 80 char limit trumps the minor aesthetic loss in this particular case.

Do I need to do something here? Or do You lose this patch from sight after re-check? @Lokal_Profil ?

I'm happy to merge as is. Consistently applying the 80 char limit trumps the minor aesthetic loss in this particular case.

Do I need to do something here? Or do You lose this patch from sight after re-check? @Lokal_Profil ?

I was awaiting a resolution here about the line breaking. I notice that Dalby has found some minor issues with the patch though.

@Lokal_Profil and where is this @Dalba commnet? I cannot see it here or on gerrit.

My mistake I looked at the other commitments mentioned in this thread.

Change 327740 merged by jenkins-bot:
newitem.py doesn't crash on LockedPage

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