Skip to content

Commit 87fd8f9

Browse files
author
Anselm Kruis
committed
Issue python#109: Don't export internal/private symbols
Previously many internal/private symbols were declared as PyAPI_DATA() or PyAPI_FUNC() and therefore visible in the python*.dll. This commit removes the PyAPI... declarations. Additionally it renames a few symbols to make the naming more consistent. https://bitbucket.org/stackless-dev/stackless/issues/109 (grafted from 3b6d1f52e108c7377944ee9c452c3d853d8882ab)
1 parent bad5a9d commit 87fd8f9

File tree

7 files changed

+156
-159
lines changed

7 files changed

+156
-159
lines changed

Python/ceval.c

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,39 +1215,47 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
12151215

12161216
#ifdef STACKLESS
12171217

1218-
f->f_execute = PyEval_EvalFrame_noval;
1219-
return PyEval_EvalFrame_value(f, throwflag, retval);
1218+
f->f_execute = slp_eval_frame_noval;
1219+
return slp_eval_frame_value(f, throwflag, retval);
12201220
exit_eval_frame:
12211221
Py_LeaveRecursiveCall();
12221222
tstate->frame = f->f_back;
12231223
return NULL;
12241224
}
12251225

12261226
PyObject *
1227-
PyEval_EvalFrame_noval(PyFrameObject *f, int throwflag, PyObject *retval)
1227+
slp_eval_frame_noval(PyFrameObject *f, int throwflag, PyObject *retval)
12281228
{
1229+
PyObject *r;
12291230
/*
12301231
* this function is identical to PyEval_EvalFrame_value.
12311232
* it serves as a marker whether we expect a value or
12321233
* not, and it makes debugging a little easier.
12331234
*/
1234-
return PyEval_EvalFrame_value(f, throwflag, retval);
1235+
Py_XINCREF(f); /* fool the link optimizer */
1236+
r = slp_eval_frame_value(f, throwflag, retval);
1237+
Py_XDECREF(f);
1238+
return r;
12351239
}
12361240

12371241
PyObject *
1238-
PyEval_EvalFrame_iter(PyFrameObject *f, int throwflag, PyObject *retval)
1242+
slp_eval_frame_iter(PyFrameObject *f, int throwflag, PyObject *retval)
12391243
{
1244+
PyObject *r;
12401245
/*
12411246
* this function is identical to PyEval_EvalFrame_value.
12421247
* it serves as a marker whether we are inside of a
12431248
* for_iter operation. In this case we need to handle
12441249
* null without error as valid result.
12451250
*/
1246-
return PyEval_EvalFrame_value(f, throwflag, retval);
1251+
Py_XINCREF(retval); /* fool the link optimizer */
1252+
r = slp_eval_frame_value(f, throwflag, retval);
1253+
Py_XDECREF(retval);
1254+
return r;
12471255
}
12481256

12491257
PyObject *
1250-
PyEval_EvalFrame_setup_with(PyFrameObject *f, int throwflag, PyObject *retval)
1258+
slp_eval_frame_setup_with(PyFrameObject *f, int throwflag, PyObject *retval)
12511259
{
12521260
PyObject *r;
12531261
/*
@@ -1258,14 +1266,14 @@ PyEval_EvalFrame_setup_with(PyFrameObject *f, int throwflag, PyObject *retval)
12581266
*/
12591267
Py_XINCREF(f); /* fool the link optimizer */
12601268
Py_XINCREF(retval); /* fool the link optimizer */
1261-
r = PyEval_EvalFrame_value(f, throwflag, retval);
1269+
r = slp_eval_frame_value(f, throwflag, retval);
12621270
Py_XDECREF(retval);
12631271
Py_XDECREF(f);
12641272
return r;
12651273
}
12661274

12671275
PyObject *
1268-
PyEval_EvalFrame_with_cleanup(PyFrameObject *f, int throwflag, PyObject *retval)
1276+
slp_eval_frame_with_cleanup(PyFrameObject *f, int throwflag, PyObject *retval)
12691277
{
12701278
PyObject *r;
12711279
/*
@@ -1276,14 +1284,14 @@ PyEval_EvalFrame_with_cleanup(PyFrameObject *f, int throwflag, PyObject *retval)
12761284
*/
12771285
Py_XINCREF(f); /* fool the link optimizer */
12781286
Py_XINCREF(f); /* fool the link optimizer */
1279-
r = PyEval_EvalFrame_value(f, throwflag, retval);
1287+
r = slp_eval_frame_value(f, throwflag, retval);
12801288
Py_XDECREF(f);
12811289
Py_XDECREF(f);
12821290
return r;
12831291
}
12841292

12851293
PyObject *
1286-
PyEval_EvalFrame_value(PyFrameObject *f, int throwflag, PyObject *retval)
1294+
slp_eval_frame_value(PyFrameObject *f, int throwflag, PyObject *retval)
12871295
{
12881296
/* unfortunately we repeat all the variables here... */
12891297
#ifdef DXPAIRS
@@ -1685,7 +1693,7 @@ PyEval_EvalFrame_value(PyFrameObject *f, int throwflag, PyObject *retval)
16851693
the generator and on the return from each yield. In Stackless, we
16861694
reenter frames for other purposes (calls, iteration, ..) and need
16871695
to avoid incorrect reexecution and exc reference leaking. */
1688-
if (f->f_execute == PyEval_EvalFrame_noval) {
1696+
if (f->f_execute == slp_eval_frame_noval) {
16891697
#endif
16901698
if (f->f_exc_type != NULL && f->f_exc_type != Py_None) {
16911699
/* We were in an except handler when we left,
@@ -1716,12 +1724,12 @@ PyEval_EvalFrame_value(PyFrameObject *f, int throwflag, PyObject *retval)
17161724

17171725

17181726
#ifdef STACKLESS
1719-
if (f->f_execute == PyEval_EvalFrame_value) {
1727+
if (f->f_execute == slp_eval_frame_value) {
17201728
/* this is a return */
17211729
PUSH(retval); /* we are back from a function call */
17221730
}
17231731
else {
1724-
if (f->f_execute == PyEval_EvalFrame_iter) {
1732+
if (f->f_execute == slp_eval_frame_iter) {
17251733
/* finalise the for_iter operation */
17261734
opcode = NEXTOP();
17271735
oparg = NEXTARG();
@@ -1752,7 +1760,7 @@ PyEval_EvalFrame_value(PyFrameObject *f, int throwflag, PyObject *retval)
17521760
JUMPBY(oparg);
17531761
}
17541762
}
1755-
else if (f->f_execute == PyEval_EvalFrame_setup_with) {
1763+
else if (f->f_execute == slp_eval_frame_setup_with) {
17561764
/* finalise the SETUP_WITH operation */
17571765
opcode = NEXTOP();
17581766
oparg = NEXTARG();
@@ -1771,7 +1779,7 @@ PyEval_EvalFrame_value(PyFrameObject *f, int throwflag, PyObject *retval)
17711779
PUSH(retval);
17721780
}
17731781
}
1774-
else if (f->f_execute == PyEval_EvalFrame_with_cleanup) {
1782+
else if (f->f_execute == slp_eval_frame_with_cleanup) {
17751783
/* finalise the WITH_CLEANUP operation */
17761784

17771785
if (retval) {
@@ -1809,10 +1817,10 @@ PyEval_EvalFrame_value(PyFrameObject *f, int throwflag, PyObject *retval)
18091817
}
18101818
else {
18111819
/* don't push it, frame ignores value */
1812-
assert (f->f_execute == PyEval_EvalFrame_noval);
1820+
assert (f->f_execute == slp_eval_frame_noval);
18131821
Py_XDECREF(retval);
18141822
}
1815-
f->f_execute = PyEval_EvalFrame_value;
1823+
f->f_execute = slp_eval_frame_value;
18161824

18171825
}
18181826

@@ -3748,16 +3756,16 @@ PyEval_EvalFrame_value(PyFrameObject *f, int throwflag, PyObject *retval)
37483756
return retval;
37493757

37503758
stackless_setup_with:
3751-
f->f_execute = PyEval_EvalFrame_setup_with;
3759+
f->f_execute = slp_eval_frame_setup_with;
37523760
goto stackless_call_with_opcode;
37533761

37543762
stackless_with_cleanup:
3755-
f->f_execute = PyEval_EvalFrame_with_cleanup;
3763+
f->f_execute = slp_eval_frame_with_cleanup;
37563764
goto stackless_call;
37573765

37583766
stackless_iter:
37593767
/* restore this opcode and enable frame to handle it */
3760-
f->f_execute = PyEval_EvalFrame_iter;
3768+
f->f_execute = slp_eval_frame_iter;
37613769
stackless_call_with_opcode:
37623770
next_instr -= (oparg >> 16) ? 6 : 3;
37633771

@@ -3776,37 +3784,37 @@ PyEval_EvalFrame_value(PyFrameObject *f, int throwflag, PyObject *retval)
37763784
STACKLESS_UNPACK(retval);
37773785
retval = tstate->frame->f_execute(tstate->frame, 0, retval);
37783786
if (tstate->frame != f) {
3779-
assert(f->f_execute == PyEval_EvalFrame_value || f->f_execute == PyEval_EvalFrame_noval ||
3780-
f->f_execute == PyEval_EvalFrame_setup_with || f->f_execute == PyEval_EvalFrame_with_cleanup);
3781-
if (f->f_execute == PyEval_EvalFrame_noval)
3782-
f->f_execute = PyEval_EvalFrame_value;
3787+
assert(f->f_execute == slp_eval_frame_value || f->f_execute == slp_eval_frame_noval ||
3788+
f->f_execute == slp_eval_frame_setup_with || f->f_execute == slp_eval_frame_with_cleanup);
3789+
if (f->f_execute == slp_eval_frame_noval)
3790+
f->f_execute = slp_eval_frame_value;
37833791
return retval;
37843792
}
37853793
if (STACKLESS_UNWINDING(retval))
37863794
STACKLESS_UNPACK(retval);
37873795

37883796
x = retval;
37893797
f->f_stacktop = NULL;
3790-
if (f->f_execute == PyEval_EvalFrame_iter) {
3798+
if (f->f_execute == slp_eval_frame_iter) {
37913799
next_instr += (oparg >> 16) ? 6 : 3;
3792-
f->f_execute = PyEval_EvalFrame_value;
3800+
f->f_execute = slp_eval_frame_value;
37933801
goto stackless_iter_return;
37943802
}
3795-
else if (f->f_execute == PyEval_EvalFrame_setup_with) {
3803+
else if (f->f_execute == slp_eval_frame_setup_with) {
37963804
next_instr += (oparg >> 16) ? 6 : 3;
3797-
f->f_execute = PyEval_EvalFrame_value;
3805+
f->f_execute = slp_eval_frame_value;
37983806
goto stackless_setup_with_return;
37993807
}
3800-
else if (f->f_execute == PyEval_EvalFrame_with_cleanup) {
3801-
f->f_execute = PyEval_EvalFrame_value;
3808+
else if (f->f_execute == slp_eval_frame_with_cleanup) {
3809+
f->f_execute = slp_eval_frame_value;
38023810
goto stackless_with_cleanup_return;
38033811
}
38043812

38053813
goto stackless_call_return;
38063814

38073815
stackless_interrupt_call:
38083816

3809-
f->f_execute = PyEval_EvalFrame_noval;
3817+
f->f_execute = slp_eval_frame_noval;
38103818
f->f_stacktop = stack_pointer;
38113819

38123820
/* the -1 is to adjust for the f_lasti change.

Stackless/changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ What's New in Stackless 3.X.X?
99

1010
*Release date: 20XX-XX-XX*
1111

12+
- https://bitbucket.org/stackless-dev/stackless/issues/109
13+
The Stackless python*.dll no longer exports private symbols. Symbols
14+
required by Stackless-aware 3rd party extension modules should still be
15+
available.
16+
1217
- https://bitbucket.org/stackless-dev/stackless/issues/108
1318
Use PyVarObject_HEAD_INIT to initialise type objects. See PEP 3123.
1419

0 commit comments

Comments
 (0)