diff options
| author | shadchin <[email protected]> | 2024-04-28 21:17:44 +0300 |
|---|---|---|
| committer | shadchin <[email protected]> | 2024-04-28 21:25:54 +0300 |
| commit | a55d99a3eb72f90355bc146baeda18aa7eb97352 (patch) | |
| tree | b17cfed786effe8b81bba022239d6729f716fbeb /contrib/tools/python3/Objects | |
| parent | 67bf49d08acf1277eff4c336021ac22d964bb4c4 (diff) | |
Update Python 3 to 3.12.3
7d09de7d8b99ea2be554ef0fc61276942ca9c2e1
Diffstat (limited to 'contrib/tools/python3/Objects')
| -rw-r--r-- | contrib/tools/python3/Objects/descrobject.c | 3 | ||||
| -rw-r--r-- | contrib/tools/python3/Objects/floatobject.c | 21 | ||||
| -rw-r--r-- | contrib/tools/python3/Objects/genobject.c | 5 | ||||
| -rw-r--r-- | contrib/tools/python3/Objects/listobject.c | 13 | ||||
| -rw-r--r-- | contrib/tools/python3/Objects/longobject.c | 63 | ||||
| -rw-r--r-- | contrib/tools/python3/Objects/typeobject.c | 1 | ||||
| -rw-r--r-- | contrib/tools/python3/Objects/unicodeobject.c | 2 |
7 files changed, 59 insertions, 49 deletions
diff --git a/contrib/tools/python3/Objects/descrobject.c b/contrib/tools/python3/Objects/descrobject.c index d5e88dcf1c8..55c0491cfd2 100644 --- a/contrib/tools/python3/Objects/descrobject.c +++ b/contrib/tools/python3/Objects/descrobject.c @@ -1697,15 +1697,12 @@ property_copy(PyObject *old, PyObject *get, PyObject *set, PyObject *del) return NULL; if (get == NULL || get == Py_None) { - Py_XDECREF(get); get = pold->prop_get ? pold->prop_get : Py_None; } if (set == NULL || set == Py_None) { - Py_XDECREF(set); set = pold->prop_set ? pold->prop_set : Py_None; } if (del == NULL || del == Py_None) { - Py_XDECREF(del); del = pold->prop_del ? pold->prop_del : Py_None; } if (pold->getter_doc && get != Py_None) { diff --git a/contrib/tools/python3/Objects/floatobject.c b/contrib/tools/python3/Objects/floatobject.c index 83a263c0d9c..7a882bfd88b 100644 --- a/contrib/tools/python3/Objects/floatobject.c +++ b/contrib/tools/python3/Objects/floatobject.c @@ -101,10 +101,18 @@ PyFloat_GetInfo(void) return NULL; } -#define SetIntFlag(flag) \ - PyStructSequence_SET_ITEM(floatinfo, pos++, PyLong_FromLong(flag)) -#define SetDblFlag(flag) \ - PyStructSequence_SET_ITEM(floatinfo, pos++, PyFloat_FromDouble(flag)) +#define SetFlag(CALL) \ + do { \ + PyObject *flag = (CALL); \ + if (flag == NULL) { \ + Py_CLEAR(floatinfo); \ + return NULL; \ + } \ + PyStructSequence_SET_ITEM(floatinfo, pos++, flag); \ + } while (0) + +#define SetIntFlag(FLAG) SetFlag(PyLong_FromLong((FLAG))) +#define SetDblFlag(FLAG) SetFlag(PyFloat_FromDouble((FLAG))) SetDblFlag(DBL_MAX); SetIntFlag(DBL_MAX_EXP); @@ -119,11 +127,8 @@ PyFloat_GetInfo(void) SetIntFlag(FLT_ROUNDS); #undef SetIntFlag #undef SetDblFlag +#undef SetFlag - if (PyErr_Occurred()) { - Py_CLEAR(floatinfo); - return NULL; - } return floatinfo; } diff --git a/contrib/tools/python3/Objects/genobject.c b/contrib/tools/python3/Objects/genobject.c index 3b9e4a60367..bc58409c181 100644 --- a/contrib/tools/python3/Objects/genobject.c +++ b/contrib/tools/python3/Objects/genobject.c @@ -374,7 +374,6 @@ static PyObject * gen_close(PyGenObject *gen, PyObject *args) { PyObject *retval; - PyObject *yf = _PyGen_yf(gen); int err = 0; if (gen->gi_frame_state == FRAME_CREATED) { @@ -384,6 +383,7 @@ gen_close(PyGenObject *gen, PyObject *args) if (gen->gi_frame_state >= FRAME_COMPLETED) { Py_RETURN_NONE; } + PyObject *yf = _PyGen_yf(gen); if (yf) { PyFrameState state = gen->gi_frame_state; gen->gi_frame_state = FRAME_EXECUTING; @@ -396,12 +396,13 @@ gen_close(PyGenObject *gen, PyObject *args) * YIELD_VALUE if the debugger has changed the lineno. */ if (err == 0 && is_yield(frame->prev_instr)) { assert(is_resume(frame->prev_instr + 1)); - int exception_handler_depth = frame->prev_instr[0].op.code; + int exception_handler_depth = frame->prev_instr[0].op.arg; assert(exception_handler_depth > 0); /* We can safely ignore the outermost try block * as it automatically generated to handle * StopIteration. */ if (exception_handler_depth == 1) { + gen->gi_frame_state = FRAME_COMPLETED; Py_RETURN_NONE; } } diff --git a/contrib/tools/python3/Objects/listobject.c b/contrib/tools/python3/Objects/listobject.c index f1edfb3a9a0..f59abe2e644 100644 --- a/contrib/tools/python3/Objects/listobject.c +++ b/contrib/tools/python3/Objects/listobject.c @@ -3441,6 +3441,7 @@ static PyObject * listiter_reduce_general(void *_it, int forward) { PyObject *list; + PyObject *iter; /* _PyEval_GetBuiltin can invoke arbitrary code, * call must be before access of iterator pointers. @@ -3448,7 +3449,7 @@ listiter_reduce_general(void *_it, int forward) /* the objects are not the same, index is of different types! */ if (forward) { - PyObject *iter = _PyEval_GetBuiltin(&_Py_ID(iter)); + iter = _PyEval_GetBuiltin(&_Py_ID(iter)); if (!iter) { return NULL; } @@ -3456,21 +3457,19 @@ listiter_reduce_general(void *_it, int forward) if (it->it_seq) { return Py_BuildValue("N(O)n", iter, it->it_seq, it->it_index); } - Py_DECREF(iter); } else { - PyObject *reversed = _PyEval_GetBuiltin(&_Py_ID(reversed)); - if (!reversed) { + iter = _PyEval_GetBuiltin(&_Py_ID(reversed)); + if (!iter) { return NULL; } listreviterobject *it = (listreviterobject *)_it; if (it->it_seq) { - return Py_BuildValue("N(O)n", reversed, it->it_seq, it->it_index); + return Py_BuildValue("N(O)n", iter, it->it_seq, it->it_index); } - Py_DECREF(reversed); } /* empty iterator, create an empty list */ list = PyList_New(0); if (list == NULL) return NULL; - return Py_BuildValue("N(N)", _PyEval_GetBuiltin(&_Py_ID(iter)), list); + return Py_BuildValue("N(N)", iter, list); } diff --git a/contrib/tools/python3/Objects/longobject.c b/contrib/tools/python3/Objects/longobject.c index 5d9b4138614..c72e1643c9f 100644 --- a/contrib/tools/python3/Objects/longobject.c +++ b/contrib/tools/python3/Objects/longobject.c @@ -1766,7 +1766,9 @@ long_to_decimal_string_internal(PyObject *aa, digit *pout, *pin, rem, tenpow; int negative; int d; - int kind; + + // writer or bytes_writer can be used, but not both at the same time. + assert(writer == NULL || bytes_writer == NULL); a = (PyLongObject *)aa; if (a == NULL || !PyLong_Check(a)) { @@ -1879,7 +1881,6 @@ long_to_decimal_string_internal(PyObject *aa, Py_DECREF(scratch); return -1; } - kind = writer->kind; } else if (bytes_writer) { *bytes_str = _PyBytesWriter_Prepare(bytes_writer, *bytes_str, strlen); @@ -1894,7 +1895,6 @@ long_to_decimal_string_internal(PyObject *aa, Py_DECREF(scratch); return -1; } - kind = PyUnicode_KIND(str); } #define WRITE_DIGITS(p) \ @@ -1942,19 +1942,23 @@ long_to_decimal_string_internal(PyObject *aa, WRITE_DIGITS(p); assert(p == *bytes_str); } - else if (kind == PyUnicode_1BYTE_KIND) { - Py_UCS1 *p; - WRITE_UNICODE_DIGITS(Py_UCS1); - } - else if (kind == PyUnicode_2BYTE_KIND) { - Py_UCS2 *p; - WRITE_UNICODE_DIGITS(Py_UCS2); - } else { - Py_UCS4 *p; - assert (kind == PyUnicode_4BYTE_KIND); - WRITE_UNICODE_DIGITS(Py_UCS4); + int kind = writer ? writer->kind : PyUnicode_KIND(str); + if (kind == PyUnicode_1BYTE_KIND) { + Py_UCS1 *p; + WRITE_UNICODE_DIGITS(Py_UCS1); + } + else if (kind == PyUnicode_2BYTE_KIND) { + Py_UCS2 *p; + WRITE_UNICODE_DIGITS(Py_UCS2); + } + else { + assert (kind == PyUnicode_4BYTE_KIND); + Py_UCS4 *p; + WRITE_UNICODE_DIGITS(Py_UCS4); + } } + #undef WRITE_DIGITS #undef WRITE_UNICODE_DIGITS @@ -1995,11 +1999,12 @@ long_format_binary(PyObject *aa, int base, int alternate, PyObject *v = NULL; Py_ssize_t sz; Py_ssize_t size_a; - int kind; int negative; int bits; assert(base == 2 || base == 8 || base == 16); + // writer or bytes_writer can be used, but not both at the same time. + assert(writer == NULL || bytes_writer == NULL); if (a == NULL || !PyLong_Check(a)) { PyErr_BadInternalCall(); return -1; @@ -2047,7 +2052,6 @@ long_format_binary(PyObject *aa, int base, int alternate, if (writer) { if (_PyUnicodeWriter_Prepare(writer, sz, 'x') == -1) return -1; - kind = writer->kind; } else if (bytes_writer) { *bytes_str = _PyBytesWriter_Prepare(bytes_writer, *bytes_str, sz); @@ -2058,7 +2062,6 @@ long_format_binary(PyObject *aa, int base, int alternate, v = PyUnicode_New(sz, 'x'); if (v == NULL) return -1; - kind = PyUnicode_KIND(v); } #define WRITE_DIGITS(p) \ @@ -2119,19 +2122,23 @@ long_format_binary(PyObject *aa, int base, int alternate, WRITE_DIGITS(p); assert(p == *bytes_str); } - else if (kind == PyUnicode_1BYTE_KIND) { - Py_UCS1 *p; - WRITE_UNICODE_DIGITS(Py_UCS1); - } - else if (kind == PyUnicode_2BYTE_KIND) { - Py_UCS2 *p; - WRITE_UNICODE_DIGITS(Py_UCS2); - } else { - Py_UCS4 *p; - assert (kind == PyUnicode_4BYTE_KIND); - WRITE_UNICODE_DIGITS(Py_UCS4); + int kind = writer ? writer->kind : PyUnicode_KIND(v); + if (kind == PyUnicode_1BYTE_KIND) { + Py_UCS1 *p; + WRITE_UNICODE_DIGITS(Py_UCS1); + } + else if (kind == PyUnicode_2BYTE_KIND) { + Py_UCS2 *p; + WRITE_UNICODE_DIGITS(Py_UCS2); + } + else { + assert (kind == PyUnicode_4BYTE_KIND); + Py_UCS4 *p; + WRITE_UNICODE_DIGITS(Py_UCS4); + } } + #undef WRITE_DIGITS #undef WRITE_UNICODE_DIGITS diff --git a/contrib/tools/python3/Objects/typeobject.c b/contrib/tools/python3/Objects/typeobject.c index 8aa07d85281..0c9a876f709 100644 --- a/contrib/tools/python3/Objects/typeobject.c +++ b/contrib/tools/python3/Objects/typeobject.c @@ -6269,6 +6269,7 @@ reduce_newobj(PyObject *obj) } else { /* args == NULL */ + Py_DECREF(copyreg); Py_DECREF(kwargs); PyErr_BadInternalCall(); return NULL; diff --git a/contrib/tools/python3/Objects/unicodeobject.c b/contrib/tools/python3/Objects/unicodeobject.c index f6787c8f8aa..ad6defb629f 100644 --- a/contrib/tools/python3/Objects/unicodeobject.c +++ b/contrib/tools/python3/Objects/unicodeobject.c @@ -516,7 +516,7 @@ unicode_check_encoding_errors(const char *encoding, const char *errors) /* Disable checks during Python finalization. For example, it allows to call _PyObject_Dump() during finalization for debugging purpose. */ - if (interp->finalizing) { + if (_PyInterpreterState_GetFinalizing(interp) != NULL) { return 0; } |
