Objets décrivant les *frames*
*****************************

type PyFrameObject
    * Part of the Limited API (as an opaque struct).*

   Structure des objets C utilisée pour décrire les objets *frame*.

   Il n'y a pas de membres publics dans cette structure.

   Modifié dans la version 3.11: Les membres de la structure API
   publique ont été retirés de l'API publique de C. Visiter l'entrée
   dans la page des nouveautés de Python pour plus détails.

Les fonctions "PyEval_GetFrame()" et "PyThreadState_GetFrame()"
peuvent être utilisées pour avoir un objet de *frame*.

Voir aussi Réflexion

PyTypeObject PyFrame_Type

   Le type des objets de *frame*. C'est le même objet que
   "types.FrameType" dans la couche de Python.

   Modifié dans la version 3.11: Précédemment, ce type était
   disponible uniquement après l'inclusion de "<frameobject.h>".

PyFrameObject *PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals, PyObject *locals)

   Create a new frame object. This function returns a *strong
   reference* to the new frame object on success, and returns "NULL"
   with an exception set on failure.

int PyFrame_Check(PyObject *obj)

   Renvoie un entier non nul si *obj* est un objet *frame*.

   Modifié dans la version 3.11: Précédemment, ce type était
   disponible uniquement après l'inclusion de "<frameobject.h>".

PyFrameObject *PyFrame_GetBack(PyFrameObject *frame)
    *Valeur de retour : nouvelle référence.*

   Renvoie la *frame* encadrant immédiatement à *frame*.

   Renvoie un *strong reference*, ou "NULL" si *frame* n'a pas de
   *frame* encadrante.

   Ajouté dans la version 3.9.

PyObject *PyFrame_GetBuiltins(PyFrameObject *frame)
    *Valeur de retour : nouvelle référence.*

   Get the *frame*'s "f_builtins" attribute.

   Renvoie un *strong reference*. Le résultat ne peut être "NULL".

   Ajouté dans la version 3.11.

PyCodeObject *PyFrame_GetCode(PyFrameObject *frame)
    *Valeur de retour : nouvelle référence.** Part of the Stable ABI
   Depuis la version 3.10.*

   Obtenir le code *frame*.

   Renvoie un *strong reference*.

   Le résultat (code *frame*) ne peut être "NULL".

   Ajouté dans la version 3.9.

PyObject *PyFrame_GetGenerator(PyFrameObject *frame)
    *Valeur de retour : nouvelle référence.*

   Obtenir le générateur, coroutine, ou un générateur asynchrone qui
   maintient cette *frame*, ou "NULL" si cette *frame* n'est pas
   maintenu par un générateur. Il ne lève pas d'exception, même si la
   valeur renvoyée est "NULL".

   Renvoie un *strong reference*, ou "NULL".

   Ajouté dans la version 3.11.

PyObject *PyFrame_GetGlobals(PyFrameObject *frame)
    *Valeur de retour : nouvelle référence.*

   Get the *frame*'s "f_globals" attribute.

   Renvoie un *strong reference*. Le résultat ne peut être "NULL".

   Ajouté dans la version 3.11.

int PyFrame_GetLasti(PyFrameObject *frame)

   Get the *frame*'s "f_lasti" attribute.

   Renvoie -1 si "frame.f_lasti" est "None".

   Ajouté dans la version 3.11.

PyObject *PyFrame_GetVar(PyFrameObject *frame, PyObject *name)
    *Valeur de retour : nouvelle référence.*

   Get the variable *name* of *frame*.

   * Return a *strong reference* to the variable value on success.

   * Raise "NameError" and return "NULL" if the variable does not
     exist.

   * Raise an exception and return "NULL" on error.

   *name* type must be a "str".

   Ajouté dans la version 3.12.

PyObject *PyFrame_GetVarString(PyFrameObject *frame, const char *name)
    *Valeur de retour : nouvelle référence.*

   Similar to "PyFrame_GetVar()", but the variable name is a C string
   encoded in UTF-8.

   Ajouté dans la version 3.12.

PyObject *PyFrame_GetLocals(PyFrameObject *frame)
    *Valeur de retour : nouvelle référence.*

   Get the *frame*'s "f_locals" attribute. If the frame refers to an
   *optimized scope*, this returns a write-through proxy object that
   allows modifying the locals. In all other cases (classes, modules,
   "exec()", "eval()") it returns the mapping representing the frame
   locals directly (as described for "locals()").

   Renvoie un *strong reference*.

   Ajouté dans la version 3.11.

   Modifié dans la version 3.13: As part of **PEP 667**, return an
   instance of "PyFrameLocalsProxy_Type".

int PyFrame_GetLineNumber(PyFrameObject *frame)
    * Part of the Stable ABI Depuis la version 3.10.*

   Renvoie le numéro de ligne que cette *frame* est en train
   d'exécuter.


Frame Locals Proxies
====================

Ajouté dans la version 3.13.

The "f_locals" attribute on a frame object is an instance of a "frame-
locals proxy". The proxy object exposes a write-through view of the
underlying locals dictionary for the frame. This ensures that the
variables exposed by "f_locals" are always up to date with the live
local variables in the frame itself.

See **PEP 667** for more information.

PyTypeObject PyFrameLocalsProxy_Type

   The type of frame "locals()" proxy objects.

int PyFrameLocalsProxy_Check(PyObject *obj)

   Return non-zero if *obj* is a frame "locals()" proxy.


Legacy Local Variable APIs
==========================

These APIs are *soft deprecated*. As of Python 3.13, they do nothing.
They exist solely for backwards compatibility.

void PyFrame_LocalsToFast(PyFrameObject *f, int clear)

   This function is *soft deprecated* and does nothing.

   Prior to Python 3.13, this function would copy the "f_locals"
   attribute of *f* to the internal "fast" array of local variables,
   allowing changes in frame objects to be visible to the interpreter.
   If *clear* was true, this function would process variables that
   were unset in the locals dictionary.

   Modifié dans la version 3.13: This function now does nothing.

void PyFrame_FastToLocals(PyFrameObject *f)

   This function is *soft deprecated* and does nothing.

   Prior to Python 3.13, this function would copy the internal "fast"
   array of local variables (which is used by the interpreter) to the
   "f_locals" attribute of *f*, allowing changes in local variables to
   be visible to frame objects.

   Modifié dans la version 3.13: This function now does nothing.

int PyFrame_FastToLocalsWithError(PyFrameObject *f)

   This function is *soft deprecated* and does nothing.

   Prior to Python 3.13, this function was similar to
   "PyFrame_FastToLocals()", but would return "0" on success, and "-1"
   with an exception set on failure.

   Modifié dans la version 3.13: This function now does nothing.

Voir aussi: **PEP 667**


Internal Frames
===============

Unless using **PEP 523**, you will not need this.

struct _PyInterpreterFrame

   The interpreter's internal frame representation.

   Ajouté dans la version 3.11.

PyObject *PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame);

   *This is Unstable API. It may change without warning in minor
   releases.*

      Return a *strong reference* to the code object for the frame.

   Ajouté dans la version 3.12.

int PyUnstable_InterpreterFrame_GetLasti(struct _PyInterpreterFrame *frame);

   *This is Unstable API. It may change without warning in minor
   releases.*

   Return the byte offset into the last executed instruction.

   Ajouté dans la version 3.12.

int PyUnstable_InterpreterFrame_GetLine(struct _PyInterpreterFrame *frame);

   *This is Unstable API. It may change without warning in minor
   releases.*

   Return the currently executing line number, or -1 if there is no
   line number.

   Ajouté dans la version 3.12.
