Objetos función
***************

Hay algunas funciones específicas para las funciones de Python.

type PyFunctionObject

   La estructura C utilizada para las funciones.

PyTypeObject PyFunction_Type

   Esta es una instancia de "PyTypeObject" y representa el tipo
   función de Python. Está expuesto a los programadores de Python como
   "types.FunctionType".

int PyFunction_Check(PyObject *o)

   Retorna verdadero si *o* es un objeto función (tiene tipo
   "PyFunction_Type"). El parámetro no debe ser "NULL". Esta función
   siempre finaliza con éxito.

PyObject *PyFunction_New(PyObject *code, PyObject *globals)
    *Return value: New reference.*

   Retorna un nuevo objeto función asociado con el objeto código
   *code*. *globals* debe ser un diccionario con las variables
   globales accesibles para la función.

   The function's docstring and name are retrieved from the code
   object. "__module__" is retrieved from *globals*. The argument
   defaults, annotations and closure are set to "NULL". "__qualname__"
   is set to the same value as the code object's "co_qualname" field.

PyObject *PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname)
    *Return value: New reference.*

   As "PyFunction_New()", but also allows setting the function
   object's "__qualname__" attribute. *qualname* should be a unicode
   object or "NULL"; if "NULL", the "__qualname__" attribute is set to
   the same value as the code object's "co_qualname" field.

   Nuevo en la versión 3.3.

PyObject *PyFunction_GetCode(PyObject *op)
    *Return value: Borrowed reference.*

   Retorna el objeto código asociado con el objeto función *op*.

PyObject *PyFunction_GetGlobals(PyObject *op)
    *Return value: Borrowed reference.*

   Retorna el diccionario global asociado con el objeto función *op*.

PyObject *PyFunction_GetModule(PyObject *op)
    *Return value: Borrowed reference.*

   Return a *borrowed reference* to the "__module__" attribute of the
   function object *op*. It can be *NULL*.

   This is normally a "string" containing the module name, but can be
   set to any other object by Python code.

PyObject *PyFunction_GetDefaults(PyObject *op)
    *Return value: Borrowed reference.*

   Retorna los valores predeterminados del argumento del objeto
   función *op*. Esto puede ser una tupla de argumentos o "NULL".

int PyFunction_SetDefaults(PyObject *op, PyObject *defaults)

   Establece los valores predeterminados del argumento para el objeto
   función *op*. *defaults* deben ser "Py_None" o una tupla.

   Lanza "SystemError" y retorna "-1" en caso de error.

PyObject *PyFunction_GetClosure(PyObject *op)
    *Return value: Borrowed reference.*

   Retorna el cierre asociado con el objeto función *op*. Esto puede
   ser "NULL" o una tupla de objetos celda.

int PyFunction_SetClosure(PyObject *op, PyObject *closure)

   Establece el cierre asociado con el objeto función *op*. *cierre*
   debe ser "Py_None" o una tupla de objetos celda.

   Lanza "SystemError" y retorna "-1" en caso de error.

PyObject *PyFunction_GetAnnotations(PyObject *op)
    *Return value: Borrowed reference.*

   Retorna las anotaciones del objeto función *op*. Este puede ser un
   diccionario mutable o "NULL".

int PyFunction_SetAnnotations(PyObject *op, PyObject *annotations)

   Establece las anotaciones para el objeto función *op*.
   *annotations* debe ser un diccionario o "Py_None".

   Lanza "SystemError" y retorna "-1" en caso de error.
