Page MenuHomePhabricator

Change in quantities broke pywikibot
Closed, ResolvedPublic

Description

@daniel broke Pywikibot in T115269 . After some digging I found https://lists.wikimedia.org/pipermail/wikidata-tech/2016-November/001050.html

I'm not happy at all about upstream breaking pywikibot yet again.

Working on Q19160832
Traceback (most recent call last):
  File "pwb.py", line 255, in <module>
    if not main():
  File "pwb.py", line 249, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "pwb.py", line 121, in run_python_file
    main_mod.__dict__)
  File "/home/mdammers/code/toollabs/bot/wikidata/painting_add_creator.py", line 320, in <module>
    main()
  File "/home/mdammers/code/toollabs/bot/wikidata/painting_add_creator.py", line 317, in main
    paintingBot.run()
  File "/home/mdammers/code/toollabs/bot/wikidata/painting_add_creator.py", line 156, in run
    creatorItem = self.getCreator(creator)
  File "/home/mdammers/code/toollabs/bot/wikidata/painting_add_creator.py", line 214, in getCreator
    if (creatoritem.get().get('labels').get('en') and creatoritem.get().get('labels').get('en').lower() == creator.lower()) or (creatoritem.get().get('aliases').get('en') and creator in creatoritem.get().get('aliases').get('en')):
  File "/home/mdammers/pywikibot/pywikibot/page.py", line 3923, in get
    data = super(ItemPage, self).get(force, *args, **kwargs)
  File "/home/mdammers/pywikibot/pywikibot/page.py", line 3538, in get
    c = Claim.fromJSON(self.repo, claim)
  File "/home/mdammers/pywikibot/pywikibot/page.py", line 4339, in fromJSON
    claim.type, lambda value, site: value)(value, site)
  File "/home/mdammers/pywikibot/pywikibot/page.py", line 4282, in <lambda>
    'quantity': lambda value, site: pywikibot.WbQuantity.fromWikibase(value),
  File "/home/mdammers/pywikibot/pywikibot/__init__.py", line 675, in fromWikibase
    upperBound = cls._todecimal(wb['upperBound'])
KeyError: u'upperBound'
<type 'exceptions.KeyError'>
CRITICAL: Closing network session.

Event Timeline

Multichill triaged this task as Unbreak Now! priority.Nov 18 2016, 10:20 PM
Multichill claimed this task.
Multichill added a subscriber: Lokal_Profil.

Thanks @Lokal_Profil for fixing and @Ladsgroup for getting it out.

Is my .err content related to this (solved by the patch)?

WARNING: WbQuantity now expects a 'site' parameter. This is needed to ensure correct handling of error bounds.
WARNING: WbQuantity now expects a 'site' parameter. This is needed to ensure correct handling of error bounds.
Traceback (most recent call last):
  File "elobot-no-user-interaction-1-month.py", line 60, in elobot
    elo_claim.setTarget(pywikibot.WbQuantity(rating))
  File "/mnt/nfs/labstore-secondary-tools-project/elobot/core/pywikibot/__init__.py", line 680, in __init__
    self.upperBound = self.amount + upperError
UnboundLocalError: local variable 'upperError' referenced before assignment

I am running

Pywikibot: [https] r-pywikibot-core.git (1f05e6f, g7627, 2016/11/22, 21:46:01, n/a)
Release version: 3.0-dev
requests version: 2.2.1

on tool labs...

Is my .err content related to this (solved by the patch)?

WARNING: WbQuantity now expects a 'site' parameter. This is needed to ensure correct handling of error bounds.
WARNING: WbQuantity now expects a 'site' parameter. This is needed to ensure correct handling of error bounds.
Traceback (most recent call last):
  File "elobot-no-user-interaction-1-month.py", line 60, in elobot
    elo_claim.setTarget(pywikibot.WbQuantity(rating))
  File "/mnt/nfs/labstore-secondary-tools-project/elobot/core/pywikibot/__init__.py", line 680, in __init__
    self.upperBound = self.amount + upperError
UnboundLocalError: local variable 'upperError' referenced before assignment

I am running

Pywikibot: [https] r-pywikibot-core.git (1f05e6f, g7627, 2016/11/22, 21:46:01, n/a)
Release version: 3.0-dev
requests version: 2.2.1

on tool labs...

See T150210. In short to support non-wikidata wikibase installations you have to pass a site object to WbQuantitiy. There is a patch to remove the need for this but someone needs to review and merge.

Is my .err content related to this (solved by the patch)?

WARNING: WbQuantity now expects a 'site' parameter. This is needed to ensure correct handling of error bounds.
WARNING: WbQuantity now expects a 'site' parameter. This is needed to ensure correct handling of error bounds.
Traceback (most recent call last):
  File "elobot-no-user-interaction-1-month.py", line 60, in elobot
    elo_claim.setTarget(pywikibot.WbQuantity(rating))
  File "/mnt/nfs/labstore-secondary-tools-project/elobot/core/pywikibot/__init__.py", line 680, in __init__
    self.upperBound = self.amount + upperError
UnboundLocalError: local variable 'upperError' referenced before assignment

I am running

Pywikibot: [https] r-pywikibot-core.git (1f05e6f, g7627, 2016/11/22, 21:46:01, n/a)
Release version: 3.0-dev
requests version: 2.2.1

on tool labs...

See T150210. In short to support non-wikidata wikibase installations you have to pass a site object to WbQuantitiy. There is a patch to remove the need for this but someone needs to review and merge.

But this error was raised when trying to edit wikidata.

But this error was raised when trying to edit wikidata.

So without the site object the function cannot determine which version of Wikibase is running. So it assumes the old version... which isn't what Wikidata runs. The followg-up patch changes it to assume the newer version as default making it work on Wikidata without the need for the site object.

Still no review or merge (pywikibot has a problem with open patches) so you might want to just modify your code to pass it a site object when creating a WbQuantitiy claim.

@Wesalius The patch has now been merged so there should be no need to modify your code. If you still encounter problems please raise them at T150210