8000 revert tuple · python/cpython@78dbf36 · GitHub
[go: up one dir, main page]

Skip to content

Commit 78dbf36

Browse files
revert tuple
1 parent 65be3fd commit 78dbf36

File tree

7 files changed

+32
-32
lines changed

7 files changed

+32
-32
lines changed

Include/internal/pycore_tuple.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
#include "pycore_stackref.h" // _PyStackRef
12-
1311
extern void _PyTuple_MaybeUntrack(PyObject *);
1412
extern void _PyTuple_DebugMallocStats(FILE *out);
1513

@@ -24,7 +22,6 @@ extern PyStatus _PyTuple_InitGlobalObjects(PyInterpreterState *);
2422

2523
extern PyObject *_PyTuple_FromArray(PyObject *const *, Py_ssize_t);
2624
PyAPI_FUNC(PyObject *)_PyTuple_FromArraySteal(PyObject *const *, Py_ssize_t);
27-
PyAPI_FUNC(PyObject *)_PyTuple_FromStackSteal(_PyStackRef const *, Py_ssize_t);
2825

2926
typedef struct {
3027
PyObject_HEAD

Objects/tupleobject.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -412,29 +412,6 @@ _PyTuple_FromArraySteal(PyObject *const *src, Py_ssize_t n)
412412
return (PyObject *)tuple;
413413
}
414414

415-
PyObject *
416-
_PyTuple_FromStackSteal(_PyStackRef const *src, Py_ssize_t n)
417-
{
418-
if (n == 0) {
419-
return tuple_get_empty();
420-
}
421-
PyTupleObject *tuple = tuple_alloc(n);
422-
if (tuple == NULL) {
423-
for (Py_ssize_t i = 0; i < n; i++) {
424-
PyStackRef_CLOSE(src[i]);
425-
}
426-
return NULL;
427-
}
428-
PyObject **dst = tuple->ob_item;
429-
for (Py_ssize_t i = 0; i < n; i++) {
430-
PyObject *item = PyStackRef_AsPyObjectNew(src[i]);
431-
dst[i] = item;
432-
}
433-
_PyObject_GC_TRACK(tuple);
434-
return (PyObject *)tuple;
435-
}
436-
437-
438415
static PyObject *
439416
tupleslice(PyTupleObject *a, Py_ssize_t ilow,
440417
Py_ssize_t ihigh)

Python/bytecodes.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,13 @@ dummy_func(
17841784
}
17851785

17861786
inst(BUILD_TUPLE, (values[oparg] -- tup)) {
1787-
PyObject *tup_o = _PyTuple_FromStackSteal(values, oparg);
1787+
STACKREFS_TO_PYOBJECTS_NEW(values, oparg, values_o);
1788+
if (values_o == NULL) {
1789+
DECREF_INPUTS();
1790+
ERROR_IF(true, error);
1791+
}
1792+
PyObject *tup_o = _PyTuple_FromArraySteal(values_o, oparg);
1793+
STACKREFS_TO_PYOBJECTS_CLEANUP(values_o);
17881794
ERROR_IF(tup_o == NULL, error);
17891795
tup = PyStackRef_FromPyObjectSteal(tup_o);
17901796
}

Python/ceval.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,12 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func,
15141514
}
15151515
else {
15161516
assert(args != NULL);
1517-
u = _PyTuple_FromStackSteal((args + n), argcount - n);
1517+
STACKREFS_TO_PYOBJECTS_NEW((_PyStackRef *)args, argcount, args_o);
1518+
if (args_o == NULL) {
1519+
goto fail_pre_positional;
1520+
}
1521+
u = _PyTuple_FromArraySteal((args_o + n), argcount - n);
1522+
STACKREFS_TO_PYOBJECTS_CLEANUP(args_o);
15181523
}
15191524
if (u == NULL) {
15201525
goto fail_post_positional;

Python/executor_cases.c.h

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/cases_generator/analyzer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,6 @@ def has_error_without_pop(op: parser.InstDef) -> bool:
408408
"_PyFrame_SetStackPointer",
409409
"_PyType_HasFeature",
410410
"PyUnicode_Concat",
411-
"_PyList_FromStackSteal",
412-
"_PyTuple_FromStackSteal",
413411
"PySlice_New",
414412
"_Py_LeaveRecursiveCallPy",
415413
"CALL_STAT_INC",
@@ -428,6 +426,7 @@ def has_error_without_pop(op: parser.InstDef) -> bool:
428426
"STACKREFS_TO_PYOBJECTS",
429427
"STACKREFS_TO_PYOBJECTS_CLEANUP",
430428
"_PyList_FromArraySteal",
429+
"_PyTuple_FromArraySteal",
431430
)
432431

433432
ESCAPING_FUNCTIONS = (

0 commit comments

Comments
 (0)
0