Page MenuHomePhabricator

interwiki.py: 'int' object has no attribute 'content'
Closed, ResolvedPublic

Description

As reported on IRC:

<dragfyre> I’m running pywikibot on a third-party wiki, and I suspect I have a problem with namespaces. Trying to run the Interwiki script results in the following error:
<dragfyre> File "./scripts/interwiki.py", line 2370, in page_empty_check
<dragfyre>     if page.namespace().content:
<dragfyre> AttributeError: 'int' object has no attribute 'content'
<dragfyre> Any thoughts on how to resolve this?

Looking at https://doc.wikimedia.org/pywikibot/master/api_ref/pywikibot.html?highlight=namespace#pywikibot.site.Namespace class pywikibot.site.Namespace hasen't any "content" related property.

Event Timeline

Xqt triaged this task as Medium priority.Sep 5 2018, 8:51 AM

class pywikibot.site.Namespace hasen't any "content" related property.

These are extra attributes passed with kwargs I guess from siteinfo.

Seems the third-party-wiki is mw < 1.16 but we support mw >= 1.14

Change 458145 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] enable Namespace.content for mw > 1.16

https://gerrit.wikimedia.org/r/458145

Seems the third-party-wiki is mw < 1.16 but we support mw >= 1.14

To be specific, we're running mw 1.29.2.

Thanks for the follow-up!

Change 458145 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] enable Namespace.content for mw < 1.16

https://gerrit.wikimedia.org/r/458145

Patch merged, @Dragfyre can you update your local repo and test if it works ? Thanks !

Still getting the same error. :(

Here's the entire stack trace and error text BTW, in case it helps:

File "pwb.py", line 253, in <module>
  if not main():
File "pwb.py", line 246, in main
  run_python_file(filename, [filename] + args, argvu, file_package)
File "pwb.py", line 115, in run_python_file
  main_mod.__dict__)
File "./scripts/interwiki.py", line 2572, in <module>
  main()
File "./scripts/interwiki.py", line 2548, in main
  bot.run()
File "./scripts/interwiki.py", line 2260, in run
  self.queryStep()
File "./scripts/interwiki.py", line 2234, in queryStep
  self.oneQuery()
File "./scripts/interwiki.py", line 2229, in oneQuery
  subject.batchLoaded(self)
File "./scripts/interwiki.py", line 1308, in batchLoaded
  elif page_empty_check(page):
File "./scripts/interwiki.py", line 2370, in page_empty_check
  if page.namespace().content:

Change 458359 had a related patch set uploaded (by Dalba; owner: dalba):
[pywikibot/core@master] pywikibot.page.Link.langlinkUnsafe: Set _namespace to a Namespace object

https://gerrit.wikimedia.org/r/458359

Change 458359 merged by jenkins-bot:
[pywikibot/core@master] page.Link.langlinkUnsafe: Always set _namespace to a Namespace object

https://gerrit.wikimedia.org/r/458359

It's working now with the latest merge. Thank you!

@Dragfyre , thanks for reporting the issue.