[issue36188] Remove vestiges of Python 2 unbound methods from Python 3
Martijn Pieters
report at bugs.python.org
Mon Mar 4 13:05:02 EST 2019
New submission from Martijn Pieters <mj at python.org>:
The implementation of method_hash, method_call and method_descr_get all still contain assumptions that __self__ can be set to None, a holdover from Python 2 where methods could be *unbound*.
These vestiges can safely be removed, because method_new() and PyMethod_New() both ensure that self is always non-null.
In addition, the datamodel description of methods includes this section:
When a user-defined method object is created by retrieving another method
object from a class or instance, the behaviour is the same as for a
function object, except that the :attr:`__func__` attribute of the new
instance is not the original method object but its :attr:`__func__`
attribute.
which also only applies to Python 2 unbound methods. Python 3 bound methods never change what they are bound to, let alone produce a new method object from __get__ that has to be careful about what __func__ is set to.
I'm submitting a PR that removes these vestiges, no need to maintain code that never runs.
----------
components: Interpreter Core
messages: 337142
nosy: mjpieters
priority: normal
severity: normal
status: open
title: Remove vestiges of Python 2 unbound methods from Python 3
versions: Python 3.6, Python 3.7, Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36188>
_______________________________________
More information about the Python-bugs-list
mailing list