[bugfix] Catch AttributeError and raise the ValueError
[bugfix] Catch AttributeError and raise the ValueError

Bug: T181913
Change-Id: Id03f32e8dc422a22f9998030836da5be8d25af52

magul/pywikibot-core,wikimedia/pywikibot-core,magul/pywikibot-core,wikimedia/pywikibot-core,PersianWikipedia/pywikibot-core