PyO3 / PyO3/pyo3

__getattr__ cannot be accessed from python by looking it up on the type

Open
#6,101 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.2k
Forks
1k
Avg merge
2d 6h
Merged PRs (30d)
66

Description

Bug Description

getattr cannot be accessed via the type's getattr slot0 wrapper.. Accessing getattr in this manner is possible for a class defined in pure Python.

Steps to Reproduce

Adding the following test to test_getattr in test_proto_methods.rs, leads to an AttributeError instead of a TypeError

         py_expect_exception!(
             py,
             example_py,
             "type(example_py).__getattr__(object(), 'test')",
             PyTypeError
        );
Backtrace

Your operating system and version

Ubuntu within the WSL

Your Python version (python --version)

Python 3.14

Your Rust version (rustc --version)

1.95

Your PyO3 version

0.28.3

How did you install python? Did you use a virtualenv?

apt and I used a venv

Additional Info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with test_getattr in test_proto_methods.rs and run the existing test to reproduce the AttributeError. Compare the type(example_py).getattr behavior with the expected PyTypeError for a pure-Python class, then confirm the test passes with the corrected slot access behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.