Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions Parser/pegen_errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "pycore_pyerrors.h" // _PyErr_ProgramDecodedTextObject()
#include "pycore_runtime.h" // _Py_ID()
#include "pycore_tuple.h" // _PyTuple_FromPair
#include "lexer/state.h"
#include "lexer/lexer.h"
#include "pegen.h"
Expand Down Expand Up @@ -41,7 +42,7 @@ _PyPegen_raise_tokenizer_init_error(PyObject *filename)
goto error;
}

tuple = PyTuple_Pack(2, errstr, tmp);
tuple = _PyTuple_FromPair(errstr, tmp);
Py_DECREF(tmp);
if (!tuple) {
goto error;
Expand Down Expand Up @@ -393,7 +394,7 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,
if (!tmp) {
goto error;
}
value = PyTuple_Pack(2, errstr, tmp);
value = _PyTuple_FromPair(errstr, tmp);
Py_DECREF(tmp);
if (!value) {
goto error;
Expand Down
3 changes: 2 additions & 1 deletion Python/Python-tokenize.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Python.h"
#include "errcode.h"
#include "internal/pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION
#include "internal/pycore_tuple.h" // _PyTuple_FromPair
#include "../Parser/lexer/state.h"
#include "../Parser/lexer/lexer.h"
#include "../Parser/tokenizer/tokenizer.h"
Expand Down Expand Up @@ -164,7 +165,7 @@ _tokenizer_error(tokenizeriterobject *it)
goto exit;
}

value = PyTuple_Pack(2, errstr, tmp);
value = _PyTuple_FromPair(errstr, tmp);
if (!value) {
result = -1;
goto exit;
Expand Down
3 changes: 2 additions & 1 deletion Python/_warnings.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "pycore_pylifecycle.h" // _Py_IsInterpreterFinalizing()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_traceback.h" // _Py_DisplaySourceLine()
#include "pycore_tuple.h" // _PyTuple_FromPair
#include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString()

#include <stdbool.h>
Expand Down Expand Up @@ -634,7 +635,7 @@ update_registry(PyInterpreterState *interp, PyObject *registry, PyObject *text,
if (add_zero)
altkey = PyTuple_Pack(3, text, category, _PyLong_GetZero());
else
altkey = PyTuple_Pack(2, text, category);
altkey = _PyTuple_FromPair(text, category);

rc = already_warned(interp, registry, altkey, 1);
Py_XDECREF(altkey);
Expand Down
2 changes: 1 addition & 1 deletion Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3341,7 +3341,7 @@ zip_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
if (lz->strict) {
return PyTuple_Pack(3, Py_TYPE(lz), lz->ittuple, Py_True);
}
return PyTuple_Pack(2, Py_TYPE(lz), lz->ittuple);
return _PyTuple_FromPair((PyObject *)Py_TYPE(lz), lz->ittuple);
}

static PyObject *
Expand Down
3 changes: 2 additions & 1 deletion Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "pycore_runtime.h" // _Py_ID()
#include "pycore_setobject.h" // _PySet_NextEntry()
#include "pycore_stats.h"
#include "pycore_tuple.h" // _PyTuple_FromPair
#include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString()

#include "cpython/code.h"
Expand Down Expand Up @@ -1697,7 +1698,7 @@ _PyCompile_CodeGen(PyObject *ast, PyObject *filename, PyCompilerFlags *pflags,
return NULL;
}
/* Allocate a copy of the instruction sequence on the heap */
res = PyTuple_Pack(2, _PyCompile_InstrSequence(c), metadata);
res = _PyTuple_FromPair((PyObject *)_PyCompile_InstrSequence(c), metadata);

finally:
Py_XDECREF(metadata);
Expand Down
3 changes: 2 additions & 1 deletion Python/hamt.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_long.h" // _PyLong_Format()
#include "pycore_object.h" // _PyObject_GC_TRACK()
#include "pycore_tuple.h" // _PyTuple_FromPair

#include <stddef.h> // offsetof()

Expand Down Expand Up @@ -2542,7 +2543,7 @@ PyTypeObject _PyHamtItems_Type = {
static PyObject *
hamt_iter_yield_items(PyObject *key, PyObject *val)
{
return PyTuple_Pack(2, key, val);
return _PyTuple_FromPair(key, val);
}

PyObject *
Expand Down
5 changes: 2 additions & 3 deletions Python/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "pycore_object.h" // _PyObject_IsUniquelyReferenced
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_setobject.h" // _PySet_NextEntryRef()
#include "pycore_tuple.h" // _PyTuple_FromPairSteal
#include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal()

#include "marshal.h" // Py_MARSHAL_VERSION
Expand Down Expand Up @@ -629,9 +630,7 @@ w_complex_object(PyObject *v, char flag, WFILE *p)
Py_DECREF(value);
break;
}
PyObject *pair = PyTuple_Pack(2, dump, value);
Py_DECREF(dump);
Py_DECREF(value);
PyObject *pair = _PyTuple_FromPairSteal(dump, value);
if (pair == NULL) {
p->error = WFERR_NOMEMORY;
break;
Expand Down
3 changes: 2 additions & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "pycore_stats.h" // _PyStats_InterpInit()
#include "pycore_sysmodule.h" // _PySys_ClearAttrString()
#include "pycore_traceback.h" // _Py_DumpTracebackThreads()
#include "pycore_tuple.h" // _PyTuple_FromPair
#include "pycore_typeobject.h" // _PyTypes_InitTypes()
#include "pycore_typevarobject.h" // _Py_clear_generic_types()
#include "pycore_unicodeobject.h" // _PyUnicode_InitTypes()
Expand Down Expand Up @@ -1613,7 +1614,7 @@ finalize_remove_modules(PyObject *modules, int verbose)
if (weaklist != NULL) { \
PyObject *wr = PyWeakref_NewRef(mod, NULL); \
if (wr) { \
PyObject *tup = PyTuple_Pack(2, name, wr); \
PyObject *tup = _PyTuple_FromPair(name, wr); \
if (!tup || PyList_Append(weaklist, tup) < 0) { \
PyErr_FormatUnraisable("Exception ignored while removing modules"); \
} \
Expand Down
Loading