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


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:

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 ( )
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 ( 
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 the solution is probably to implement either cmp ( ) or the more specific ones:

  •, other)
  • object.le(self, other)
  • object.eq(self, other)
  •, other)
  •, other)

*, 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()



To: Multichill
Cc: Aklapper, pywikibot-bugs-list, Multichill, MayS, Mdupont, JJMC89, jayvdb, Ricordisamoa, Wesalius, Alchimista, Rxy
pywikibot-bugs mailing list

Reply via email to