Page MenuHomePhabricator

Wikibase does not accept "+g"-formatted strings as quantities
Closed, DuplicatePublic

Description

import pywikibot
repo = pywikibot.Site('wikidata', 'wikidata')
item = pywikibot.ItemPage(repo, 'Q209351')
claim = item.get()['claims']['P2370'][0]
print(claim.getTarget())
claim.getTarget().upperBound = claim.getTarget().lowerBound = None
item.editEntity(summary='remove explicit bounds')

Prints:

{
    "amount": "+1e-28",
    "lowerBound": "+1e-28",
    "unit": "http://www.wikidata.org/entity/Q25343",
    "upperBound": "+1e-28"
}

Result: WARNING: API error modification-failed: Data value corrupt: "+1e-28" is not a well formed decimal value

Per https://www.wikidata.org/wiki/Special:EntityData/Q209351.json, Pywikibot recieves values like "+0.0000000000000000000000000001" (strings) but these are handled using Decimal and then saved as "+1e-28" (format(value, "+g")). Either Wikibase should be updated to accept values in such a format or Pywikibot shouldn't submit them.

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptSep 14 2018, 10:49 AM
Addshore added a project: DataValues.EditedSep 19 2018, 7:20 AM
Addshore added a subscriber: Addshore.

For parser in DataValues would need to be updated to handle values such as this.

The question is, do we want to accept values like this?
My gut says probably yes..

Hi,

I'm encountering the same problem. I also have seen that this is related to this:

https://phabricator.wikimedia.org/T119226

D063520