Xqt added a comment.

The old implementation had the KeyError too but the test didn't fail which is curious:

C:\pwb\GIT\core>py -2 pwb.py tests/isbn_tests -v TestIsbnWikibaseBot
tests: max_retries reduced from 15 to 1
test_isbn1 (__main__.TestIsbnWikibaseBot)
Test 1 using the bot and wikibase. ... Assuming that ISBN-10 property is P360.
Assuming that ISBN-13 property is P366.
Retrieving 1 pages from wikidata:test.


>>> Q943 <<<
Changing P360 (ISBN 097522980x --> 0-9752298-0-X)
>####
{u'id': u'Q943$fe3a849c-4c9f-2037-ae29-658443937c01',
 u'mainsnak': {u'datatype': u'string',
               u'datavalue': {u'type': u'string', u'value': u'0-9752298-0-X'},
               u'property': u'P360',
               u'snaktype': u'value'},
 u'rank': u'normal',
 u'type': u'statement'}
<####
{
    "claims": {
        "P360": [
            {
                "id": "Q943$fe3a849c-4c9f-2037-ae29-658443937c01",
                "mainsnak": {
                    "datatype": "string",
                    "datavalue": {
                        "type": "string",
                        "value": "0-9752298-0-X"
                    },
                    "property": "P360",
                    "snaktype": "value"
                },
                "rank": "normal",
                "type": "statement"
            }
        ]
    }
}
Change summary: Bot: Formatting ISBN
ok
test_isbn2 (__main__.TestIsbnWikibaseBot)
Test 1 using the bot and wikibase. ... WARNING: C:\pwb\GIT\core\pywikibot\bot.py
:856: UserWarning: Site objects have been created before arguments were handled
Assuming that ISBN-10 property is P360.
Assuming that ISBN-13 property is P366.
Retrieving 1 pages from wikidata:test.


>>> Q943 <<<
Changing P360 (ISBN 097522980x) to P366 (ISBN 978-0975229804)
>####
{u'mainsnak': {u'datatype': u'string',
               u'datavalue': {u'type': u'string',
                              u'value': u'ISBN 978-0975229804'},
               u'property': u'P366',
               u'snaktype': u'value'},
 u'rank': u'normal',
 u'type': u'statement'}
<####
ERROR: u'id'
Traceback (most recent call last):
  File "C:\pwb\GIT\core\pywikibot\bot.py", line 2030, in run
    self.treat(page, item)
  File "C:\pwb\GIT\core\scripts\isbn.py", line 1626, in treat
    self.user_edit_entity(item, summary=self.comment)
  File "C:\pwb\GIT\core\pywikibot\bot.py", line 1916, in user_edit_entity
    item._content if hasattr(item, '_content') else None))
  File "C:\pwb\GIT\core\pywikibot\page.py", line 4293, in toJSON
    data = "" self).toJSON(diffto=diffto)
  File "C:\pwb\GIT\core\pywikibot\page.py", line 3884, in toJSON
    claim_ids.add(claim['id'])
KeyError: u'id'ok

----------------------------------------------------------------------
Ran 2 tests in 5.347s

OK

C:\pwb\GIT\core>

TASK DETAIL
https://phabricator.wikimedia.org/T174870

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Xqt
Cc: gerritbot, Dalba, murfel, m4tx, matej_suchanek, Aklapper, Xqt, pywikibot-bugs-list, Lordiis, Adik2382, Th3d3v1ls, Ramalepe, Liugev6, Magul, Tbscho, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, Avicennasis, jayvdb, Masti, Alchimista, Rxy
_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to