Page MenuHomePhabricator

Page/__init__.py: WikibaseEntity
Closed, ResolvedPublic

Description

On the page/__init__ file, in the class WikibaseEntity, there is function called getattr(), and it's returns at the end (line 3239): super().getattr(). The problem is that WikibaseEntity have no super class... I didn't understand what it's supposed to do so I can't fix it.

Details

Event Timeline

Xqt subscribed.

WikibaseEntity is implicit derived from object and each object has this method. Therefore this call is valid.

But when I did something it's raised an exception because of that.

Could you please file the traceback of that exception please.

Ok, it's only if I try to get invalid value:

import pywikibot
site = pywikibot.Site('he', 'wikisource')
page = pywikibot.Page(site, 'קטגוריה:רבי אבא')
item = pywikibot.ItemPage.fromPage(page)
item.abc
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
  start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
  exec(open(mainpyfile).read(),  __main__.__dict__)
File "<string>", line 5, in <module>
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/pywikibot/page/__init__.py", line 3755, in __getattr__
  return super().__getattr__(name)
AttributeError: 'super' object has no attribute '__getattr__'
CRITICAL: Exiting due to uncaught exception <class 'AttributeError'>

[Program finished]

Xqt triaged this task as High priority.Apr 28 2021, 9:26 PM

Cannot reproduce it:

C:\pwb\GIT\core>pwb shell
Welcome to the Pywikibot interactive shell!
>>> s = pywikibot.Site('wikisource:he')
>>> p = pywikibot.Page(s, 'קטגוריה:רבי אבא')
>>> i = pywikibot.ItemPage.fromPage(p)
>>> i
ItemPage('Q7221758')
>>>

What is your result of pwb version?

Cannot reproduce it:

You are supposed to call item.abc, then it seems to fail. This should fail either, but the error message should rather be "there is nothing like abc" than "there is no getattr on super". Might be my mistake.

I think you tried to do something but it's not working. so if name not in self.DATA_ATTRIBUTES we need to raise an exception or warning, and delete the last line of the func...

Change 683820 had a related patch set uploaded (by Matěj Suchánek; author: Matěj Suchánek):

[pywikibot/core@master] [bugfix] Fix __getattr__ for WikibasePage and WikibaseEntity

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

Change 683820 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Fix __getattr__ for WikibaseEntity

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

Xqt claimed this task.