Python3 C extension how to support dir()

Barry Scott barry at
Fri Apr 14 15:33:59 EDT 2017

I have an python3 C++ extension that works.
But dir(obj) does not return the list of member variables.

How should I support dir() from the C API?

I cannot use tp_members, not appropiate to the code I'm writing.
If I provide __dir__ I then hit the problem I need the C API version

	all_attr = super( mytype, obj ).__dir__();
	all_attr.extend( mytype_variable_names );

I'm not getting inspiration from the python 3.6 sources for this problem.
I did find the object_dir function in typeobject.c, but that has not helped
get me forward.

What am I missing?


More information about the Python-list mailing list