◐ Shell
clean mode source ↗

Fix classmethod descr_get to match CPython behavior by ever0de · Pull Request #7420 · RustPython/RustPython

@ever0de ever0de marked this pull request as ready for review

March 13, 2026 14:00

coderabbitai[bot]

  Simplify classmethod.__get__ to always create a PyBoundMethod binding
  the callable to the class, matching CPython's cm_descr_get which simply
  calls PyMethod_New(cm->cm_callable, type).

  The previous implementation incorrectly tried to call __get__ on the
  wrapped callable, which broke when a bound method was passed to
  classmethod() (e.g. classmethod(A().foo)).

youknowone

youknowone pushed a commit to youknowone/RustPython that referenced this pull request

Mar 19, 2026
Simplify classmethod.__get__ to always create a PyBoundMethod binding
  the callable to the class, matching CPython's cm_descr_get which simply
  calls PyMethod_New(cm->cm_callable, type).

  The previous implementation incorrectly tried to call __get__ on the
  wrapped callable, which broke when a bound method was passed to
  classmethod() (e.g. classmethod(A().foo)).

youknowone pushed a commit to youknowone/RustPython that referenced this pull request

Mar 22, 2026
Simplify classmethod.__get__ to always create a PyBoundMethod binding
  the callable to the class, matching CPython's cm_descr_get which simply
  calls PyMethod_New(cm->cm_callable, type).

  The previous implementation incorrectly tried to call __get__ on the
  wrapped callable, which broke when a bound method was passed to
  classmethod() (e.g. classmethod(A().foo)).