mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 02:10:27 +00:00
stopped segfaults on tests
all tests pass in MODE= also ported oneline changes: python/cpython@a3070d530c python/cpython@c6ea8974e2
This commit is contained in:
parent
9c78780c04
commit
2b53efd719
4 changed files with 17 additions and 31 deletions
18
third_party/python/Modules/_collectionsmodule.c
vendored
18
third_party/python/Modules/_collectionsmodule.c
vendored
|
@ -936,14 +936,10 @@ done:
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
deque_rotate(dequeobject *deque, PyObject **args, Py_ssize_t nargs,
|
deque_rotate(dequeobject *deque, PyObject **args, Py_ssize_t nargs)
|
||||||
PyObject *kwnames)
|
|
||||||
{
|
{
|
||||||
Py_ssize_t n=1;
|
Py_ssize_t n=1;
|
||||||
|
|
||||||
if (!_PyArg_NoStackKeywords("rotate", kwnames)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!_PyArg_ParseStack(args, nargs, "|n:rotate", &n)) {
|
if (!_PyArg_ParseStack(args, nargs, "|n:rotate", &n)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1076,8 +1072,7 @@ deque_len(dequeobject *deque)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
deque_index(dequeobject *deque, PyObject **args, Py_ssize_t nargs,
|
deque_index(dequeobject *deque, PyObject **args, Py_ssize_t nargs)
|
||||||
PyObject *kwnames)
|
|
||||||
{
|
{
|
||||||
Py_ssize_t i, n, start=0, stop=Py_SIZE(deque);
|
Py_ssize_t i, n, start=0, stop=Py_SIZE(deque);
|
||||||
PyObject *v, *item;
|
PyObject *v, *item;
|
||||||
|
@ -1086,9 +1081,6 @@ deque_index(dequeobject *deque, PyObject **args, Py_ssize_t nargs,
|
||||||
size_t start_state = deque->state;
|
size_t start_state = deque->state;
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
if (!_PyArg_NoStackKeywords("index", kwnames)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!_PyArg_ParseStack(args, nargs, "O|O&O&:index", &v,
|
if (!_PyArg_ParseStack(args, nargs, "O|O&O&:index", &v,
|
||||||
_PyEval_SliceIndex, &start,
|
_PyEval_SliceIndex, &start,
|
||||||
_PyEval_SliceIndex, &stop)) {
|
_PyEval_SliceIndex, &stop)) {
|
||||||
|
@ -1157,17 +1149,13 @@ PyDoc_STRVAR(index_doc,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
deque_insert(dequeobject *deque, PyObject **args, Py_ssize_t nargs,
|
deque_insert(dequeobject *deque, PyObject **args, Py_ssize_t nargs)
|
||||||
PyObject *kwnames)
|
|
||||||
{
|
{
|
||||||
Py_ssize_t index;
|
Py_ssize_t index;
|
||||||
Py_ssize_t n = Py_SIZE(deque);
|
Py_ssize_t n = Py_SIZE(deque);
|
||||||
PyObject *value;
|
PyObject *value;
|
||||||
PyObject *rv;
|
PyObject *rv;
|
||||||
|
|
||||||
if (!_PyArg_NoStackKeywords("insert", kwnames)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!_PyArg_ParseStack(args, nargs, "nO:insert", &index, &value)) {
|
if (!_PyArg_ParseStack(args, nargs, "nO:insert", &index, &value)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
7
third_party/python/Modules/_elementtree.c
vendored
7
third_party/python/Modules/_elementtree.c
vendored
|
@ -2806,6 +2806,9 @@ typedef struct {
|
||||||
|
|
||||||
} XMLParserObject;
|
} XMLParserObject;
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
_elementtree_XMLParser_doctype(XMLParserObject* self, PyObject** args,
|
||||||
|
Py_ssize_t nargs);
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_elementtree_XMLParser_doctype_impl(XMLParserObject *self, PyObject *name,
|
_elementtree_XMLParser_doctype_impl(XMLParserObject *self, PyObject *name,
|
||||||
PyObject *pubid, PyObject *system);
|
PyObject *pubid, PyObject *system);
|
||||||
|
@ -3222,7 +3225,7 @@ expat_start_doctype_handler(XMLParserObject *self,
|
||||||
!(PyCFunction_Check(parser_doctype) &&
|
!(PyCFunction_Check(parser_doctype) &&
|
||||||
PyCFunction_GET_SELF(parser_doctype) == self_pyobj &&
|
PyCFunction_GET_SELF(parser_doctype) == self_pyobj &&
|
||||||
PyCFunction_GET_FUNCTION(parser_doctype) ==
|
PyCFunction_GET_FUNCTION(parser_doctype) ==
|
||||||
(PyCFunction) _elementtree_XMLParser_doctype_impl)) {
|
(PyCFunction) _elementtree_XMLParser_doctype)) {
|
||||||
res = _elementtree_XMLParser_doctype_impl(self, doctype_name_obj,
|
res = _elementtree_XMLParser_doctype_impl(self, doctype_name_obj,
|
||||||
pubid_obj, sysid_obj);
|
pubid_obj, sysid_obj);
|
||||||
if (!res)
|
if (!res)
|
||||||
|
@ -3808,7 +3811,7 @@ static PyMethodDef element_methods[] = {
|
||||||
_ELEMENTTREE_ELEMENT_ITERTEXT_METHODDEF
|
_ELEMENTTREE_ELEMENT_ITERTEXT_METHODDEF
|
||||||
_ELEMENTTREE_ELEMENT_ITERFIND_METHODDEF
|
_ELEMENTTREE_ELEMENT_ITERFIND_METHODDEF
|
||||||
|
|
||||||
{"getiterator", (PyCFunction)_elementtree_Element_iter, METH_FASTCALL, _elementtree_Element_iter__doc__},
|
{"getiterator", (PyCFunction)_elementtree_Element_iter, METH_FASTCALL | METH_KEYWORDS, _elementtree_Element_iter__doc__},
|
||||||
_ELEMENTTREE_ELEMENT_GETCHILDREN_METHODDEF
|
_ELEMENTTREE_ELEMENT_GETCHILDREN_METHODDEF
|
||||||
|
|
||||||
_ELEMENTTREE_ELEMENT_ITEMS_METHODDEF
|
_ELEMENTTREE_ELEMENT_ITEMS_METHODDEF
|
||||||
|
|
14
third_party/python/Modules/_struct.c
vendored
14
third_party/python/Modules/_struct.c
vendored
|
@ -1870,7 +1870,7 @@ to the format string S.format. See help(struct) for more on format\n\
|
||||||
strings.");
|
strings.");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
s_pack(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
s_pack(PyObject *self, PyObject **args, Py_ssize_t nargs)
|
||||||
{
|
{
|
||||||
PyStructObject *soself;
|
PyStructObject *soself;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
@ -1885,9 +1885,6 @@ s_pack(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||||
"pack expected %zd items for packing (got %zd)", soself->s_len, nargs);
|
"pack expected %zd items for packing (got %zd)", soself->s_len, nargs);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!_PyArg_NoStackKeywords("pack", kwnames)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate a new string */
|
/* Allocate a new string */
|
||||||
result = PyBytes_FromStringAndSize((char *)NULL, soself->s_size);
|
result = PyBytes_FromStringAndSize((char *)NULL, soself->s_size);
|
||||||
|
@ -1912,7 +1909,7 @@ offset. Note that the offset is a required argument. See\n\
|
||||||
help(struct) for more on format strings.");
|
help(struct) for more on format strings.");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
s_pack_into(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
s_pack_into(PyObject *self, PyObject **args, Py_ssize_t nargs)
|
||||||
{
|
{
|
||||||
PyStructObject *soself;
|
PyStructObject *soself;
|
||||||
Py_buffer buffer;
|
Py_buffer buffer;
|
||||||
|
@ -1939,9 +1936,6 @@ s_pack_into(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!_PyArg_NoStackKeywords("pack_into", kwnames)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Extract a writable memory buffer from the first argument */
|
/* Extract a writable memory buffer from the first argument */
|
||||||
if (!PyArg_Parse(args[0], "w*", &buffer))
|
if (!PyArg_Parse(args[0], "w*", &buffer))
|
||||||
|
@ -2162,7 +2156,7 @@ pack(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||||
if (s_object == NULL) {
|
if (s_object == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
result = s_pack((PyObject *)s_object, args + 1, nargs - 1, kwnames);
|
result = s_pack((PyObject *)s_object, args + 1, nargs - 1);
|
||||||
Py_DECREF(s_object);
|
Py_DECREF(s_object);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2191,7 +2185,7 @@ pack_into(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||||
if (s_object == NULL) {
|
if (s_object == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
result = s_pack_into((PyObject *)s_object, args + 1, nargs - 1, kwnames);
|
result = s_pack_into((PyObject *)s_object, args + 1, nargs - 1);
|
||||||
Py_DECREF(s_object);
|
Py_DECREF(s_object);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
9
third_party/python/Objects/call.c
vendored
9
third_party/python/Objects/call.c
vendored
|
@ -400,7 +400,7 @@ _PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs,
|
||||||
|
|
||||||
result = _PyEval_EvalCodeWithName((PyObject*)co, globals, (PyObject *)NULL,
|
result = _PyEval_EvalCodeWithName((PyObject*)co, globals, (PyObject *)NULL,
|
||||||
args, nargs,
|
args, nargs,
|
||||||
k, k + 1, nk, 2,
|
k, k != NULL ? k + 1 : NULL, nk, 2,
|
||||||
d, nd, kwdefs,
|
d, nd, kwdefs,
|
||||||
closure, name, qualname);
|
closure, name, qualname);
|
||||||
Py_XDECREF(kwtuple);
|
Py_XDECREF(kwtuple);
|
||||||
|
@ -879,9 +879,10 @@ _PyObject_FastCall_Prepend(PyObject *callable,
|
||||||
|
|
||||||
/* use borrowed references */
|
/* use borrowed references */
|
||||||
args2[0] = obj;
|
args2[0] = obj;
|
||||||
memcpy(&args2[1],
|
if (nargs > 1)
|
||||||
args,
|
{
|
||||||
(nargs - 1)* sizeof(PyObject *));
|
memcpy(&args2[1], args, (nargs - 1) * sizeof(PyObject *));
|
||||||
|
}
|
||||||
|
|
||||||
result = _PyObject_FastCall(callable, args2, nargs);
|
result = _PyObject_FastCall(callable, args2, nargs);
|
||||||
if (args2 != small_stack) {
|
if (args2 != small_stack) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue