summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-11-08 23:09:27 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-11-08 23:09:27 (GMT)
commitdc945e4943a17fc6f15e35ccef506ad75e878545 (patch)
tree26a670cb6cf5c8c8a6328234f2cd034374c556bb
parentfba5dc18009df4dad9f6e251ad9a3b8a8e1a2542 (diff)
parenta3ad8a0ce7e87a36886410c9314d3f338e844048 (diff)
downloadcpython-dc945e4943a17fc6f15e35ccef506ad75e878545.zip
cpython-dc945e4943a17fc6f15e35ccef506ad75e878545.tar.gz
cpython-dc945e4943a17fc6f15e35ccef506ad75e878545.tar.bz2
#16440: merge with 3.3.
-rw-r--r--Doc/library/stdtypes.rst24
1 files changed, 15 insertions, 9 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index cd07fa7..27be4f5 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -3343,16 +3343,22 @@ arg-n)``.
Like function objects, bound method objects support getting arbitrary
attributes. However, since method attributes are actually stored on the
underlying function object (``meth.__func__``), setting method attributes on
-bound methods is disallowed. Attempting to set a method attribute results in a
-:exc:`TypeError` being raised. In order to set a method attribute, you need to
-explicitly set it on the underlying function object::
+bound methods is disallowed. Attempting to set an attribute on a method
+results in an :exc:`AttributeError` being raised. In order to set a method
+attribute, you need to explicitly set it on the underlying function object::
- class C:
- def method(self):
- pass
-
- c = C()
- c.method.__func__.whoami = 'my name is c'
+ >>> class C:
+ ... def method(self):
+ ... pass
+ ...
+ >>> c = C()
+ >>> c.method.whoami = 'my name is method' # can't set on the method
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ AttributeError: 'method' object has no attribute 'whoami'
+ >>> c.method.__func__.whoami = 'my name is method'
+ >>> c.method.whoami
+ 'my name is method'
See :ref:`types` for more information.