Multichill created this task.
Multichill added projects: Pywikibot-Wikidata, Pywikibot-core.
Herald added subscribers: pywikibot-bugs-list, Aklapper.

TASK DESCRIPTION

I'm doing some checks before adding the country of citizenship (P27) to persons. The check is quite simple: Did the country already exist during the lifetime of a person. Seemed to work quite well so I was puzzled to see this edit: https://www.wikidata.org/w/index.php?title=Q4271168&type=revision&diff=388967975&oldid=306952066

Peter Le Lievre (Q4271168) lived 1812-1878 and United Kingdom (Q145) has inception (P571) 12 April 1927. Why did the bot add it?

Code to reproduce:

import pywikibot
repo = pywikibot.Site().data_repository()
# Our person is Peter Le Lievre (https://www.wikidata.org/wiki/Q4271168 )
personitem = pywikibot.ItemPage(repo, u'Q4271168')
persondata = personitem.get()
personclaims = persondata.get('claims')

dateofbirth = personclaims.get(u'P569')[0].getTarget()
dateofdeath = personclaims.get(u'P570')[0].getTarget()


# Suggested country is United Kingdom ( https://www.wikidata.org/wiki/Q145 
countryitem = pywikibot.ItemPage(repo, u'Q145')
countrydata = countryitem.get()
countryclaims = countrydata.get('claims')
countryinception = countryclaims.get(u'P571')[0].getTarget()

print dateofbirth
print dateofdeath
print countryinception

# Dateofbirth is smaller than dateofdeath so I expect true here
print dateofbirth < dateofdeath

# Dateofbirth is smaller than countryinception so I expect true here
print dateofbirth < countryinception

# BUG!

Looking at https://docs.python.org/2/reference/datamodel.html#basic-customization the solution is probably to implement either cmp ( https://docs.python.org/2/reference/datamodel.html#object.__cmp__ ) or the more specific ones:

  • object.lt(self, other)
  • object.le(self, other)
  • object.eq(self, other)
  • object.ne(self, other)
  • object.gt(self, other)

*object.ge(self, other)

From the manual: " If no cmp(), eq() or ne() operation is defined, class instances are compared by object identity (“address”)."

Probably easiest to just compare the output for both toTimestr()


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

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

To: Multichill
Cc: Aklapper, pywikibot-bugs-list, Multichill, MayS, Mdupont, JJMC89, jayvdb, Ricordisamoa, Wesalius, Alchimista, Rxy
_______________________________________________
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to