| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0983fcd commit b727239
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -578,12 +578,6 @@ Callable types | |||
| 578 | 578 | to be bound. The new method's :attr:`__func__` attribute is the original | |
| 579 | 579 | function object. | |
| 580 | 580 | ||
| 581 | - When a user-defined method object is created by retrieving another method | ||
| 582 | - object from a class or instance, the behaviour is the same as for a | ||
| 583 | - function object, except that the :attr:`__func__` attribute of the new | ||
| 584 | - instance is not the original method object but its :attr:`__func__` | ||
| 585 | - attribute. | ||
| 586 | - | ||
| 587 | 581 | When an instance method object is created by retrieving a class method | |
| 588 | 582 | object from a class or instance, its :attr:`__self__` attribute is the | |
| 589 | 583 | class itself, and its :attr:`__func__` attribute is the function object | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Cleaned up left-over vestiges of Python 2 unbound method handling in method objects and documentation. | ||
| 2 | + Patch by Martijn Pieters | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -267,10 +267,7 @@ static Py_hash_t | |||
| 267 | 267 | method_hash(PyMethodObject *a) | |
| 268 | 268 | { | |
| 269 | 269 | Py_hash_t x, y; | |
| 270 | - if (a->im_self == NULL) | ||
| 271 | - x = _Py_HashPointer(Py_None); | ||
| 272 | - else | ||
| 273 | - x = _Py_HashPointer(a->im_self); | ||
| 270 | + x = _Py_HashPointer(a->im_self); | ||
| 274 | 271 | y = PyObject_Hash(a->im_func); | |
| 275 | 272 | if (y == -1) | |
| 276 | 273 | return -1; | |
@@ -294,11 +291,6 @@ method_call(PyObject *method, PyObject *args, PyObject *kwargs) | |||
| 294 | 291 | PyObject *self, *func; | |
| 295 | 292 | ||
| 296 | 293 | self = PyMethod_GET_SELF(method); | |
| 297 | - if (self == NULL) { | ||
| 298 | - PyErr_BadInternalCall(); | ||
| 299 | - return NULL; | ||
| 300 | - } | ||
| 301 | - | ||
| 302 | 294 | func = PyMethod_GET_FUNCTION(method); | |
| 303 | 295 | ||
| 304 | 296 | return _PyObject_Call_Prepend(func, self, args, kwargs); | |
@@ -307,15 +299,8 @@ method_call(PyObject *method, PyObject *args, PyObject *kwargs) | |||
| 307 | 299 | static PyObject * | |
| 308 | 300 | method_descr_get(PyObject *meth, PyObject *obj, PyObject *cls) | |
| 309 | 301 | { | |
| 310 | - /* Don't rebind an already bound method of a class that's not a base | ||
| 311 | - class of cls. */ | ||
| 312 | - if (PyMethod_GET_SELF(meth) != NULL) { | ||
| 313 | - /* Already bound */ | ||
| 314 | - Py_INCREF(meth); | ||
| 315 | - return meth; | ||
| 316 | - } | ||
| 317 | - /* Bind it to obj */ | ||
| 318 | - return PyMethod_New(PyMethod_GET_FUNCTION(meth), obj); | ||
| 302 | + Py_INCREF(meth); | ||
| 303 | + return meth; | ||
| 319 | 304 | } | |
| 320 | 305 | ||
| 321 | 306 | PyTypeObject PyMethod_Type = { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments