Skip to content

gh-72088: clarify inspect.ismethod returns False for class-level access#146505

Open
Das-Chinmay wants to merge 1 commit intopython:mainfrom
Das-Chinmay:fix-inspect-ismethod-docs
Open

gh-72088: clarify inspect.ismethod returns False for class-level access#146505
Das-Chinmay wants to merge 1 commit intopython:mainfrom
Das-Chinmay:fix-inspect-ismethod-docs

Conversation

@Das-Chinmay
Copy link
Copy Markdown

@Das-Chinmay Das-Chinmay commented Mar 27, 2026

inspect.ismethod() returns False when a method is accessed through the
class rather than an instance (because the result is a plain function, not a
bound method). This trips up users coming from Python 2, where unbound methods
existed. The current one-liner docstring gives no hint of this behaviour.

Adds a short note and a cross-reference to the instance-methods section of
the language reference so readers can understand why.

Fixes gh-72088

  • Base: python/cpython:main
  • Head: Das-Chinmay:fix-inspect-ismethod-docs

📚 Documentation preview 📚: https://cpython-previews--146505.org.readthedocs.build/

…l access

Accessing a method through the class returns a plain function, not a
bound method, so ismethod() returns False in that case.  Add a note
and a cross-reference to the 'instance methods' section of the data
model reference to explain this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

DOC: inspect.ismethod returns different results on the same basic code between Python2.7 Python3.5

1 participant