diff options
author | Guido van Rossum <guido@python.org> | 2001-09-21 19:29:08 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-09-21 19:29:08 (GMT) |
commit | 867a8d2e2688d837c67bf87eb9164528780f7bdc (patch) | |
tree | 17384a0aba0c05752f3d10e2ca18838d1ed815f7 /Lib | |
parent | dbb718fa8775731666bb9cbc73662fadee41ea8f (diff) | |
download | cpython-867a8d2e2688d837c67bf87eb9164528780f7bdc.zip cpython-867a8d2e2688d837c67bf87eb9164528780f7bdc.tar.gz cpython-867a8d2e2688d837c67bf87eb9164528780f7bdc.tar.bz2 |
Change the name of the __getattr__ special method for new-style
classes to __getattribute__, to make it crystal-clear that it doesn't
have the same semantics as overriding __getattr__ on classic classes.
This is a halfway checkin -- I'll proceed to add a __getattr__ hook
that works the way it works in classic classes.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_descr.py | 12 | ||||
-rw-r--r-- | Lib/test/test_descrtut.py | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 426b2d4..bbd4372 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -678,9 +678,9 @@ def pymods(): class MM(MT): def __init__(self): MT.__init__(self) - def __getattr__(self, name): + def __getattribute__(self, name): log.append(("getattr", name)) - return MT.__getattr__(self, name) + return MT.__getattribute__(self, name) def __setattr__(self, name, value): log.append(("setattr", name, value)) MT.__setattr__(self, name, value) @@ -881,8 +881,8 @@ def dynamics(): if name == "spam": return "spam" else: - return object.__getattr__(self, name) - C.__getattr__ = mygetattr + return object.__getattribute__(self, name) + C.__getattribute__ = mygetattr verify(a.spam == "spam") a.new = 12 verify(a.new == 12) @@ -1105,11 +1105,11 @@ def overloading(): class C(B): - def __getattr__(self, name): + def __getattribute__(self, name): if name == "foo": return ("getattr", name) else: - return B.__getattr__(self, name) + return B.__getattribute__(self, name) def __setattr__(self, name, value): if name == "foo": self.setattr = (name, value) diff --git a/Lib/test/test_descrtut.py b/Lib/test/test_descrtut.py index a0fe0f1..e72567d 100644 --- a/Lib/test/test_descrtut.py +++ b/Lib/test/test_descrtut.py @@ -192,7 +192,7 @@ Instead, you can get the same information from the list type: '__delitem__', '__eq__', '__ge__', - '__getattr__', + '__getattribute__', '__getitem__', '__getslice__', '__gt__', |