Problems with dict and C API
Matjaz
surfmatj at email.si
Tue Sep 7 05:40:10 EDT 2004
Alex,
thank you for this valuable piece of information. I will
indeed try to use mapping protocol as much as possible.
However, I am curious of the following: were the
functions for setting/getting items (should be PyMapping_SetItem
and PyMapping_GetItem, like that for object and dictionaries)
left out on purpose, because there exist
only "string" versions PyMapping_SetItemString and
PyMapping_GetItemString?
Matjaz.
Alex Martelli wrote:
>
> PyIntance_New wants specifically an old-style class as its first
> argument, and you're not giving that in the latter case (a subclass of
> dict is intrinsically new-style) so it's diagnosing that and raising the
> exception you see. Just use PyObject_Call and you should be fine. More
> generally, use abstract-object-layer API calls unless you've got very
> specific reasons to use something lower-level (concrete layer) -- 90%+
> of the time you'll be far happied with the AOL calls.
>
> BTW, to get sys.modules, I suggest you use PyImport_GetModuleDict()
> rather than PySys_GetObject("modules") -- it's slightly more direct.
>
>
> Alex
More information about the Python-list
mailing list