8000 bpo-43693: Add _PyCode_New() and do some related cleanup. by ericsnowcurrently · Pull Request #26258 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-43693: Add _PyCode_New() and do some related cleanup. #26258

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
dce5124
Re-organize the _PyCodeObject fields.
ericsnowcurrently May 18, 2021
e416918
Spell out the PyCode_New*() signatures.
ericsnowcurrently May 18, 2021
6740572
Add a TODO to code.h.
ericsnowcurrently May 18, 2021
4381869
Fix a memory leak.
ericsnowcurrently May 18, 2021
19cfb8b
Add _PyCode_New().
ericsnowcurrently May 18, 2021
8f10f5d
Factor out _PyCode_GetFastlocalOffsetId().
ericsnowcurrently May 18, 2021
0c42221
Factor out _PyCode_HasFastlocals().
ericsnowcurrently May 18, 2021
3315b28
Factor out _PyCode_CellForLocal().
ericsnowcurrently May 18, 2021
2ac48ba
Add macros to hide away some of the PyCodeObject fields.
ericsnowcurrently May 19, 2021
02e15a4
Move the fast locals section down.
ericsnowcurrently May 19, 2021
ad70f99
Store more counts on PyCodeObject.
ericsnowcurrently May 19, 2021
e38643f
Update a comment.
ericsnowcurrently May 19, 2021
09fbe71
Factor out macros related to co_code.
ericsnowcurrently May 14, 2021
9b4ca77
Fix some smelly names.
ericsnowcurrently May 20, 2021
f00133f
Fix whitespace.
ericsnowcurrently May 20, 2021
acef742
Fix co_nlocals in code.replace().
ericsnowcurrently May 20, 2021
559e408
Stop using statics in PyCode_NewEmpty().
ericsnowcurrently May 20, 2021
a923b5b
Actually fix whitespace.
ericsnowcurrently May 20, 2021
afcc944
Fix a typo.
ericsnowcurrently May 20, 2021
d304aba
Replace macros with inline functions.
ericsnowcurrently May 20, 2021
23e5485
Unify all the PyCodeObject validation code.
ericsnowcurrently May 20, 2021
81c4a49
Fix the logged function name.
ericsnowcurrently May 20, 2021
af51553
Fix the GDB script.
ericsnowcurrently May 21, 2021
cc3f435
-_PyCode_GetFastlocalOffsetId -> _PyCode_FastOffsetFromId().
ericsnowcurrently May 21, 2021
fcf4ea3
Fix CO_FAST_KWONLY.
ericsnowcurrently May 21, 2021
cb82a6a
Fix a typo.
ericsnowcurrently May 21, 2021
672a75f
Make sure int is used for fast offsets and PyCodeObject counts.
ericsnowcurrently May 22, 2021
32907b1
Fix the comment about fields in hash/comparision.
ericsnowcurrently May 22, 2021
aee3640
Drop co_nlocals from marshaled code objects.
ericsnowcurrently May 22, 2021
fd50f62
Regen a couple more files.
ericsnowcurrently May 22, 2021
9736ff5
Fix test_ctypes.
ericsnowcurrently May 22, 2021
c95314c
Factor out CO_FAST_ARG.
ericsnowcurrently May 24, 2021
b419060
Fix a typo.
ericsnowcurrently May 24, 2021
6195184
Add an assert for the return value of frame_nslots().
ericsnowcurrently May 24, 2021
3c4ec94
Add a comment about using an arguments struct for _PyCode_New().
ericsnowcurrently May 24, 2021
ffc4b54
Drop some outdated TODO comments.
ericsnowcurrently May 24, 2021
292b646
Fix a typo.
ericsnowcurrently May 24, 2021
cd9e34a
Add _PyCode_FastInfoFromOffset().
ericsnowcurrently May 24, 2021
cd4f587
Add _PyCode_GetFastFreevar().
ericsnowcurrently May 24, 2021
a4e6dd3
Use _PyCode_FastInfoFromOffset() elsewhere in ceval.c.
ericsnowcurrently May 24, 2021
f93b6df
Add _PyCode_OffsetFromIndex().
ericsnowcurrently May 24, 2021
f779627
_PyCode_FastInfoFromOffset() -> _PyCode_FastInfoFromOparg().
ericsnowcurrently May 24, 2021
292e457
Add _PyCode_FastInfoFromOffset() and use it in frameobject.c.
ericsnowcurrently May 24, 2021
f6bafb4
Fix warnings.
ericsnowcurrently May 24, 2021
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
_PyCode_FastInfoFromOffset() -> _PyCode_FastInfoFromOparg().
  • Loading branch information
ericsnowcurrently committed May 24, 2021
commit f7796274311cd05f987d871a39aa89c449d5aa72
6 changes: 3 additions & 3 deletions Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ PyAPI_FUNC(PyCodeObject *) _PyCode_New(struct _PyCodeConstructor *);
int _PyCode_InitOpcache(PyCodeObject *co);

PyAPI_FUNC(bool) _PyCode_HasFastlocals(PyCodeObject *, _PyFastLocalKind);
PyAPI_FUNC(void) _PyCode_FastInfoFromOffset(PyCodeObject *, int,
_PyFastLocalKind,
PyObject **, _PyFastLocalKind *);
PyAPI_FUNC(void) _PyCode_FastInfoFromOparg(PyCodeObject *, int,
_PyFastLocalKind,
PyObject **, _PyFastLocalKind *);
PyAPI_FUNC(int) _PyCode_OffsetFromIndex(PyCodeObject *, int, _PyFastLocalKind);
PyAPI_FUNC(int) _PyCode_CellForLocal(PyCodeObject *, int);

Expand Down
6 changes: 3 additions & 3 deletions Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,9 @@ _PyCode_HasFastlocals(PyCodeObject *co, _PyFastLocalKind kind)
}

void
_PyCode_FastInfoFromOffset(PyCodeObject *co, int offset,
_PyFastLocalKind expected,
PyObject **pname, _PyFastLocalKind *pkind)
_PyCode_FastInfoFromOparg(PyCodeObject *co, int offset,
_PyFastLocalKind expected,
PyObject **pname, _PyFastLocalKind *pkind)
{
assert(offset >= 0);
assert(expected > 0);
Expand Down
16 changes: 8 additions & 8 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1820,9 +1820,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
case TARGET(LOAD_FAST): {
PyObject *value = GETLOCAL(oparg);
if (value == NULL) {
PyObject *name = NULL;
_PyCode_FastInfoFromOffset(co, oparg, CO_FAST_LOCAL,
&name, NULL);
PyObject *name;
_PyCode_FastInfoFromOparg(co, oparg, CO_FAST_LOCAL,
&name, NULL);
format_exc_check_arg(tstate, PyExc_UnboundLocalError,
UNBOUNDLOCAL_ERROR_MSG, name);
goto error;
Expand Down Expand Up @@ -3049,8 +3049,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
SETLOCAL(oparg, NULL);
DISPATCH();
}
PyObject *name = NULL;
_PyCode_FastInfoFromOffset(co, oparg, CO_FAST_LOCAL, &name, NULL);
PyObject *name;
_PyCode_FastInfoFromOparg(co, oparg, CO_FAST_LOCAL, &name, NULL);
format_exc_check_arg(tstate, PyExc_UnboundLocalError,
UNBOUNDLOCAL_ERROR_MSG, name);
goto error;
Expand Down Expand Up @@ -6427,10 +6427,10 @@ format_exc_unbound(PyThreadState *tstate, PyCodeObject *co, int oparg)
if (_PyErr_Occurred(tstate)) {
return;
}
PyObject *name = NULL;
PyObject *name;
_PyFastLocalKind kind;
_PyCode_FastInfoFromOffset(co, oparg, CO_FAST_CELL | CO_FAST_FREE,
&name, &kind);
_PyCode_FastInfoFromOparg(co, oparg, CO_FAST_CELL | CO_FAST_FREE,
&name, &kind);
if (kind & CO_FAST_CELL) {
format_exc_check_arg(tstate, PyExc_UnboundLocalError,
UNBOUNDLOCAL_ERROR_MSG, name);
Expand Down
0