Skip to content

Commit c40bc09

Browse files
committed
Issue #13783: the PEP 380 implementation no longer expands the public C API
1 parent 8d5c0b8 commit c40bc09

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

Include/genobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ PyAPI_DATA(PyTypeObject) PyGen_Type;
3434

3535
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
3636
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
37-
PyAPI_FUNC(int) PyGen_FetchStopIterationValue(PyObject **);
37+
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
3838
PyObject *_PyGen_Send(PyGenObject *, PyObject *);
3939

4040
#ifdef __cplusplus

Include/pyerrors.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,6 @@ PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
400400
const char *reason /* UTF-8 encoded string */
401401
);
402402

403-
/* create a StopIteration exception with the given value */
404-
PyAPI_FUNC(PyObject *) PyStopIteration_Create(PyObject *);
405-
406403
/* These APIs aren't really part of the error implementation, but
407404
often needed to format error messages; the native C lib APIs are
408405
not available on all platforms, which is why we provide emulations

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ Library
111111
- Issue #14963: Convert contextlib.ExitStack.__exit__ to use an iterative
112112
algorithm (Patch by Alon Horev)
113113

114+
C-API
115+
-----
116+
117+
- Issue #13783: Inadvertent additions to the public C API in the PEP 380
118+
implementation have either been removed or marked as private interfaces.
119+
114120
Extension Modules
115121
-----------------
116122

Objects/exceptions.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,6 @@ StopIteration_traverse(PyStopIterationObject *self, visitproc visit, void *arg)
516516
return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg);
517517
}
518518

519-
PyObject *
520-
PyStopIteration_Create(PyObject *value)
521-
{
522-
return PyObject_CallFunctionObjArgs(PyExc_StopIteration, value, NULL);
523-
}
524-
525519
ComplexExtendsException(
526520
PyExc_Exception, /* base */
527521
StopIteration, /* name */

Objects/genobject.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc)
9797
/* Delay exception instantiation if we can */
9898
PyErr_SetNone(PyExc_StopIteration);
9999
} else {
100-
PyObject *e = PyStopIteration_Create(result);
100+
PyObject *e = PyObject_CallFunctionObjArgs(
101+
PyExc_StopIteration, result, NULL);
101102
if (e != NULL) {
102103
PyErr_SetObject(PyExc_StopIteration, e);
103104
Py_DECREF(e);
@@ -339,7 +340,7 @@ gen_throw(PyGenObject *gen, PyObject *args)
339340
Py_DECREF(ret);
340341
/* Termination repetition of YIELD_FROM */
341342
gen->gi_frame->f_lasti++;
342-
if (PyGen_FetchStopIterationValue(&val) == 0) {
343+
if (_PyGen_FetchStopIterationValue(&val) == 0) {
343344
ret = gen_send_ex(gen, val, 0);
344345
Py_DECREF(val);
345346
} else {
@@ -428,7 +429,7 @@ gen_iternext(PyGenObject *gen)
428429
*/
429430

430431
int
431-
PyGen_FetchStopIterationValue(PyObject **pvalue) {
432+
_PyGen_FetchStopIterationValue(PyObject **pvalue) {
432433
PyObject *et, *ev, *tb;
433434
PyObject *value = NULL;
434435

Python/ceval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1852,7 +1852,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
18521852
PyObject *val;
18531853
x = POP(); /* Remove iter from stack */
18541854
Py_DECREF(x);
1855-
err = PyGen_FetchStopIterationValue(&val);
1855+
err = _PyGen_FetchStopIterationValue(&val);
18561856
if (err < 0) {
18571857
x = NULL;
18581858
break;

0 commit comments

Comments
 (0)