Method and getattr wierdness in a C extension

Ignacio Vazquez-Abrams ignacio at openservices.net
Sun Aug 19 00:13:33 EDT 2001


On Sat, 18 Aug 2001, Ignacio Vazquez-Abrams wrote:

> I'm building a Python 1.5 module for libxml2 (not so much for public
> consumption so much as to teach myself both libxml2 and Python extensions) and
> I'm coming across something odd.
>
>   [snip]
>
> Here's what I'm getting at the prompt:
>
> ---
> >>> doc.copy(123)
> <xmlDocument at 80f4fc0>
> >>> doc.copy(123)
> TypeError: function requires exactly 0 arguments; 1 given
> >>> doc.copy(123)
> <xmlDocument at 80eac00>
> >>> doc.copy(123)
> TypeError: function requires exactly 0 arguments; 1 given
> >>>
> ---
>
> Why is it alternating between working and not working?

Never mind, I just solved it as follows:

   ...
  if (PyTuple_Size(args))
  {
    PyErr_SetString(PyExc_TypeError, "function requires no arguments");
    return NULL;
  };
   ...

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>





More information about the Python-list mailing list