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>
.
-
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)¶
Renvoie la frame encadrant immédiatement à frame.
Renvoie un strong reference, ou
NULL
si frame n'a pas de frame encadrante.Nouveau dans la version 3.9.
-
PyObject *PyFrame_GetBuiltins(PyFrameObject *frame)¶
Get the frame's
f_builtins
attribute.Renvoie un strong reference. Le résultat ne peut être
NULL
.Nouveau dans la version 3.11.
-
PyCodeObject *PyFrame_GetCode(PyFrameObject *frame)¶
- Part of the Stable ABI since version 3.10.
Obtenir le code frame.
Renvoie un strong reference.
Le résultat (code frame) ne peut être
NULL
.Nouveau dans la version 3.9.
-
PyObject *PyFrame_GetGenerator(PyFrameObject *frame)¶
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 estNULL
.Renvoie un strong reference, ou
NULL
.Nouveau dans la version 3.11.
-
PyObject *PyFrame_GetGlobals(PyFrameObject *frame)¶
Get the frame's
f_globals
attribute.Renvoie un strong reference. Le résultat ne peut être
NULL
.Nouveau dans la version 3.11.
-
int PyFrame_GetLasti(PyFrameObject *frame)¶
Get the frame's
f_lasti
attribute.Renvoie -1 si
frame.f_lasti
estNone
.Nouveau dans la version 3.11.
-
PyObject *PyFrame_GetVar(PyFrameObject *frame, PyObject *name)¶
Get the variable name of frame.
Return a strong reference to the variable value on success.
Raise
NameError
and returnNULL
if the variable does not exist.Raise an exception and return
NULL
on error.
name type must be a
str
.Nouveau dans la version 3.12.
-
PyObject *PyFrame_GetVarString(PyFrameObject *frame, const char *name)¶
Similar to
PyFrame_GetVar()
, but the variable name is a C string encoded in UTF-8.Nouveau dans la version 3.12.
-
PyObject *PyFrame_GetLocals(PyFrameObject *frame)¶
Get the frame's
f_locals
attribute (dict
).Renvoie un strong reference.
Nouveau dans la version 3.11.
-
int PyFrame_GetLineNumber(PyFrameObject *frame)¶
- Part of the Stable ABI since version 3.10.
Renvoie le numéro de ligne que cette frame est en train d'exécuter.
Internal Frames¶
Unless using PEP 523, you will not need this.
-
struct _PyInterpreterFrame¶
The interpreter's internal frame representation.
Nouveau 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.
Nouveau 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.
Nouveau 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.
Nouveau dans la version 3.12.