Skip to content

Fix _as_numpy_array: use variable obj instead of string literal "obj"#14472

Merged
bluetech merged 2 commits into
pytest-dev:mainfrom
algojogacor:fix/hasattr-obj-variable
May 14, 2026
Merged

Fix _as_numpy_array: use variable obj instead of string literal "obj"#14472
bluetech merged 2 commits into
pytest-dev:mainfrom
algojogacor:fix/hasattr-obj-variable

Conversation

@algojogacor

Copy link
Copy Markdown
Contributor

The second hasattr call in _as_numpy_array incorrectly passed the string literal "obj" instead of the variable obj when checking for __array_interface__. This caused objects implementing only __array_interface__ (without __array__) to not be recognized as numpy-like arrays by pytest.approx.

Closes #14456

The second hasattr call in _as_numpy_array incorrectly passed the
string literal "obj" instead of the variable obj when checking for
__array_interface__. This caused objects implementing only
__array_interface__ (without __array__) to not be recognized as
numpy-like arrays by pytest.approx.

Closes #14456
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label May 13, 2026
Comment thread changelog/14456.bugfix.rst Outdated
@bluetech bluetech enabled auto-merge (squash) May 14, 2026 09:25
@bluetech bluetech merged commit 21be7a2 into pytest-dev:main May 14, 2026
33 checks passed
@patchback

patchback Bot commented May 14, 2026

Copy link
Copy Markdown

Backport to 9.0.x: 💚 backport PR created

✅ Backport PR branch: patchback/backports/9.0.x/21be7a259424e509e3d667082a138bcc8fc45c00/pr-14472

Backported as #14480

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

bluetech added a commit that referenced this pull request Jun 2, 2026
…1be7a259424e509e3d667082a138bcc8fc45c00/pr-14472

[PR #14472/21be7a25 backport][9.0.x] Fix _as_numpy_array: use variable obj instead of string literal "obj"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_as_numpy_array: hasattr uses string literal 'obj' instead of variable

2 participants