This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bug in use of __getattribute__ ?
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, ninou
Priority: normal Keywords:

Created on 2005-08-10 16:29 by ninou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg26013 - (view) Author: sylvain ferriol (ninou) Date: 2005-08-10 16:29
hello, why it do not work:
class xx(object):
  def __getattribute__(self,name):
      tab = object.__getattribute__(self,'tab')
      return tab[name]
  def f(self,a):
      self.a=a
x=xx()
xx.tab={'f':xx.f}
x.f(3)
unbound method f() must be called with xx instance as
first argument (got int instance instead)
msg26014 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-08-10 17:04
Logged In: YES 
user_id=1188172

This is not a bug. x.f results (via getattribute) in xx.f,
which is an "unbound method" (a method of a class that does
not belong to a specific instance) and as such has no
knowledge of your instance "x".

Please post first comp.lang.python in the future, as such
things are almost always a programmer's mistake.

Closing as Invalid.
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42266
2005-08-10 16:29:17ninoucreate