X Tutup
Skip to content

BUG: Show allocatable arrays in dir() for f2py modules#30965

Open
HaoZeke wants to merge 1 commit intonumpy:mainfrom
HaoZeke:fix/f2py-allocatable-dir
Open

BUG: Show allocatable arrays in dir() for f2py modules#30965
HaoZeke wants to merge 1 commit intonumpy:mainfrom
HaoZeke:fix/f2py-allocatable-dir

Conversation

@HaoZeke
Copy link
Member

@HaoZeke HaoZeke commented Mar 8, 2026

Add a __dir__ method to PyFortranObject that includes all defs names (routines, variables, and allocatable arrays), not just the keys in the object dict. Previously, allocatable arrays were accessible via getattr but invisible to dir() because PyFortranObject_New only populated the dict with routines and non-allocatable variables.

Closes #27696

cc @2sn (sorry for the long delay)

@HaoZeke HaoZeke requested a review from melissawm March 8, 2026 15:26
@HaoZeke HaoZeke force-pushed the fix/f2py-allocatable-dir branch from c7bad11 to 0791365 Compare March 8, 2026 15:35
@HaoZeke HaoZeke changed the title BUG: Show allocatable arrays in dir() for F2PY modules BUG: Show allocatable arrays in dir() for f2py modules Mar 8, 2026
@HaoZeke HaoZeke force-pushed the fix/f2py-allocatable-dir branch from 0791365 to ff3a5f8 Compare March 8, 2026 20:16
Add a __dir__ method to PyFortranObject that includes variable names
from the defs array (which contains allocatable arrays) alongside the
regular dict keys. Previously dir() only showed dict contents, hiding
allocatable variables that are handled dynamically via getattr.

Closes numpy#27696
@HaoZeke HaoZeke force-pushed the fix/f2py-allocatable-dir branch from ff3a5f8 to 9a12dbd Compare March 8, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Allocatable array variables don't show up in dir

1 participant

X Tutup