8000 bpo-42990: Introduce 'frame constructor' struct to simplify API for PyEval_CodeEval and friends by markshannon · Pull Request #24298 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-42990: Introduce 'frame constructor' struct to simplify API for PyEval_CodeEval and friends #24298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use anonymous union and struct in PyFunctionObject to maintain backwa…
…rds compatibility.
  • Loading branch information
markshannon committed Jan 28, 2021
commit 958a4d223cf62e637426d47ecf77fda7d7332b9d
26 changes: 20 additions & 6 deletions Include/funcobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,21 @@ typedef struct {

typedef struct {
PyObject_HEAD
PyFrameConstructor func_descr; /* Frame descriptor fields for this function */
union {
PyFrameConstructor func_descr; /* Frame descriptor fields for this function */
/* This struct is for backward compatibility of code using the old func_* fields;
Note that the order of fields must match PyFrameConstructor *exactly*. */
struct {
PyObject *func_globals;
PyObject *func_builtins;
PyObject *func_name;
PyObject *func_qualname;
PyObject *func_code;
PyObject *func_defaults;
PyObject *func_kwdefaults;
PyObject *func_closure;
};
};
PyObject *func_doc; /* The __doc__ attribute, can be anything */
PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */
PyObject *func_weakreflist; /* List of weak references */
Expand Down Expand Up @@ -76,17 +90,17 @@ PyAPI_FUNC(PyObject *) _PyFunction_Vectorcall(
/* Macros for direct access to these values. Type checks are *not*
done, so use with care. */
#define PyFunction_GET_CODE(func) \
(((PyFunctionObject *)func) -> func_descr.code)
(((PyFunctionObject *)func) -> func_code)
#define PyFunction_GET_GLOBALS(func) \
(((PyFunctionObject *)func) -> func_descr.globals)
(((PyFunctionObject *)func) -> func_globals)
#define PyFunction_GET_MODULE(func) \
(((PyFunctionObject *)func) -> func_module)
#define PyFunction_GET_DEFAULTS(func) \
(((PyFunctionObject *)func) -> func_descr.defaults)
(((PyFunctionObject *)func) -> func_defaults)
#define PyFunction_GET_KW_DEFAULTS(func) \
(((PyFunctionObject *)func) -> func_descr.kwdefaults)
(((PyFunctionObject *)func) -> func_kwdefaults)
#define PyFunction_GET_CLOSURE(func) \
(((PyFunctionObject *)func) -> func_descr.closure)
(((PyFunctionObject *)func) -> func_closure)
#define PyFunction_GET_ANNOTATIONS(func) \
(((PyFunctionObject *)func) -> func_annotations)

Expand Down
0