From 23e4c54190f585653420f75bbda085a3ed71fedc Mon Sep 17 00:00:00 2001 From: Mariano Anaya Date: Sun, 28 May 2017 20:57:00 +0200 Subject: [PATCH] Descriptor HowTo: update Function.__get__ The creation of the method like in the example did not work, because in Python 3.6 ``MethodType`` takes 2 arguments (not 3). In Python 2 works, so the fix is for Python 3.6 and up. --- Doc/howto/descriptor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index c2bf473e1ff9ea..2dd6c34e2ced02 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -282,7 +282,7 @@ this:: . . . def __get__(self, obj, objtype=None): "Simulate func_descr_get() in Objects/funcobject.c" - return types.MethodType(self, obj, objtype) + return types.MethodType(self, obj) Running the interpreter shows how the function descriptor works in practice::