Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove vestiges of Python 2 unbound methods from Python 3 #80369

Closed
mjpieters mannequin opened this issue Mar 4, 2019 · 2 comments
Closed

Remove vestiges of Python 2 unbound methods from Python 3 #80369

mjpieters mannequin opened this issue Mar 4, 2019 · 2 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@mjpieters
Copy link
Mannequin

mjpieters mannequin commented Mar 4, 2019

BPO 36188
Nosy @mjpieters, @benjaminp
PRs
  • bpo-36188: Clean up 'unbound' method left-overs #12169
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-03-05.05:19:38.219>
    created_at = <Date 2019-03-04.18:05:02.760>
    labels = ['interpreter-core', '3.7', '3.8']
    title = 'Remove vestiges of Python 2 unbound methods from Python 3'
    updated_at = <Date 2019-03-05.05:19:38.210>
    user = 'https://github.com/mjpieters'

    bugs.python.org fields:

    activity = <Date 2019-03-05.05:19:38.210>
    actor = 'benjamin.peterson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-03-05.05:19:38.219>
    closer = 'benjamin.peterson'
    components = ['Interpreter Core']
    creation = <Date 2019-03-04.18:05:02.760>
    creator = 'mjpieters'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36188
    keywords = ['patch']
    message_count = 2.0
    messages = ['337142', '337167']
    nosy_count = 2.0
    nosy_names = ['mjpieters', 'benjamin.peterson']
    pr_nums = ['12169']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue36188'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @mjpieters
    Copy link
    Mannequin Author

    mjpieters mannequin commented Mar 4, 2019

    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.

    @mjpieters mjpieters mannequin added 3.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Mar 4, 2019
    @benjaminp
    Copy link
    Contributor

    New changeset b727239 by Benjamin Peterson (Martijn Pieters) in branch 'master':
    closes bpo-36188: Clean up 'unbound' method left-overs. (GH-12169)
    b727239

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant