Compare commits
4 Commits
9e8fe1986c
...
7c83eaa536
Author | SHA1 | Date |
---|---|---|
Hai Shi | 7c83eaa536 | |
Erlend Egeberg Aasland | b8eb376590 | |
Zackery Spytz | 6613676861 | |
Zackery Spytz | 5d3553b0a8 |
|
@ -198,7 +198,7 @@ However, for reading convenience, most of the examples show sorted sequences.
|
||||||
|
|
||||||
.. versionadded:: 3.6
|
.. versionadded:: 3.6
|
||||||
|
|
||||||
.. versionchanged:: 3.8
|
.. versionchanged:: 3.10
|
||||||
Added support for *weights*.
|
Added support for *weights*.
|
||||||
|
|
||||||
.. function:: median(data)
|
.. function:: median(data)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix undefined behavior in ``Objects/genericaliasobject.c``.
|
|
@ -2977,18 +2977,42 @@ static PyType_Spec arrayiter_spec = {
|
||||||
|
|
||||||
/*********************** Install Module **************************/
|
/*********************** Install Module **************************/
|
||||||
|
|
||||||
|
static int
|
||||||
|
array_traverse(PyObject *module, visitproc visit, void *arg)
|
||||||
|
{
|
||||||
|
array_state *state = get_array_state(module);
|
||||||
|
Py_VISIT(state->ArrayType);
|
||||||
|
Py_VISIT(state->ArrayIterType);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
array_clear(PyObject *module)
|
||||||
|
{
|
||||||
|
array_state *state = get_array_state(module);
|
||||||
|
Py_CLEAR(state->ArrayType);
|
||||||
|
Py_CLEAR(state->ArrayIterType);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
array_free(void *module)
|
||||||
|
{
|
||||||
|
array_clear((PyObject *)module);
|
||||||
|
}
|
||||||
|
|
||||||
/* No functions in array module. */
|
/* No functions in array module. */
|
||||||
static PyMethodDef a_methods[] = {
|
static PyMethodDef a_methods[] = {
|
||||||
ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF
|
ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF
|
||||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CREATE_TYPE(module, type, spec) \
|
#define CREATE_TYPE(module, type, spec) \
|
||||||
do { \
|
do { \
|
||||||
type = (PyTypeObject *)PyType_FromModuleAndSpec(m, spec, NULL); \
|
type = (PyTypeObject *)PyType_FromModuleAndSpec(module, spec, NULL); \
|
||||||
if (type == NULL) { \
|
if (type == NULL) { \
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -3059,6 +3083,9 @@ static struct PyModuleDef arraymodule = {
|
||||||
.m_doc = module_doc,
|
.m_doc = module_doc,
|
||||||
.m_methods = a_methods,
|
.m_methods = a_methods,
|
||||||
.m_slots = arrayslots,
|
.m_slots = arrayslots,
|
||||||
|
.m_traverse = array_traverse,
|
||||||
|
.m_clear = array_clear,
|
||||||
|
.m_free = array_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1836,6 +1836,13 @@ error:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
pyexpat_destructor(PyObject *op)
|
||||||
|
{
|
||||||
|
void *p = PyCapsule_GetPointer(op, PyExpat_CAPSULE_NAME);
|
||||||
|
PyMem_Free(p);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pyexpat_exec(PyObject *mod)
|
pyexpat_exec(PyObject *mod)
|
||||||
{
|
{
|
||||||
|
@ -1921,40 +1928,46 @@ pyexpat_exec(PyObject *mod)
|
||||||
MYCONST(XML_PARAM_ENTITY_PARSING_ALWAYS);
|
MYCONST(XML_PARAM_ENTITY_PARSING_ALWAYS);
|
||||||
#undef MYCONST
|
#undef MYCONST
|
||||||
|
|
||||||
static struct PyExpat_CAPI capi;
|
struct PyExpat_CAPI *capi = PyMem_Calloc(1, sizeof(struct PyExpat_CAPI));
|
||||||
|
if (capi == NULL) {
|
||||||
|
PyErr_NoMemory();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
/* initialize pyexpat dispatch table */
|
/* initialize pyexpat dispatch table */
|
||||||
capi.size = sizeof(capi);
|
capi->size = sizeof(*capi);
|
||||||
capi.magic = PyExpat_CAPI_MAGIC;
|
capi->magic = PyExpat_CAPI_MAGIC;
|
||||||
capi.MAJOR_VERSION = XML_MAJOR_VERSION;
|
capi->MAJOR_VERSION = XML_MAJOR_VERSION;
|
||||||
capi.MINOR_VERSION = XML_MINOR_VERSION;
|
capi->MINOR_VERSION = XML_MINOR_VERSION;
|
||||||
capi.MICRO_VERSION = XML_MICRO_VERSION;
|
capi->MICRO_VERSION = XML_MICRO_VERSION;
|
||||||
capi.ErrorString = XML_ErrorString;
|
capi->ErrorString = XML_ErrorString;
|
||||||
capi.GetErrorCode = XML_GetErrorCode;
|
capi->GetErrorCode = XML_GetErrorCode;
|
||||||
capi.GetErrorColumnNumber = XML_GetErrorColumnNumber;
|
capi->GetErrorColumnNumber = XML_GetErrorColumnNumber;
|
||||||
capi.GetErrorLineNumber = XML_GetErrorLineNumber;
|
capi->GetErrorLineNumber = XML_GetErrorLineNumber;
|
||||||
capi.Parse = XML_Parse;
|
capi->Parse = XML_Parse;
|
||||||
capi.ParserCreate_MM = XML_ParserCreate_MM;
|
capi->ParserCreate_MM = XML_ParserCreate_MM;
|
||||||
capi.ParserFree = XML_ParserFree;
|
capi->ParserFree = XML_ParserFree;
|
||||||
capi.SetCharacterDataHandler = XML_SetCharacterDataHandler;
|
capi->SetCharacterDataHandler = XML_SetCharacterDataHandler;
|
||||||
capi.SetCommentHandler = XML_SetCommentHandler;
|
capi->SetCommentHandler = XML_SetCommentHandler;
|
||||||
capi.SetDefaultHandlerExpand = XML_SetDefaultHandlerExpand;
|
capi->SetDefaultHandlerExpand = XML_SetDefaultHandlerExpand;
|
||||||
capi.SetElementHandler = XML_SetElementHandler;
|
capi->SetElementHandler = XML_SetElementHandler;
|
||||||
capi.SetNamespaceDeclHandler = XML_SetNamespaceDeclHandler;
|
capi->SetNamespaceDeclHandler = XML_SetNamespaceDeclHandler;
|
||||||
capi.SetProcessingInstructionHandler = XML_SetProcessingInstructionHandler;
|
capi->SetProcessingInstructionHandler = XML_SetProcessingInstructionHandler;
|
||||||
capi.SetUnknownEncodingHandler = XML_SetUnknownEncodingHandler;
|
capi->SetUnknownEncodingHandler = XML_SetUnknownEncodingHandler;
|
||||||
capi.SetUserData = XML_SetUserData;
|
capi->SetUserData = XML_SetUserData;
|
||||||
capi.SetStartDoctypeDeclHandler = XML_SetStartDoctypeDeclHandler;
|
capi->SetStartDoctypeDeclHandler = XML_SetStartDoctypeDeclHandler;
|
||||||
capi.SetEncoding = XML_SetEncoding;
|
capi->SetEncoding = XML_SetEncoding;
|
||||||
capi.DefaultUnknownEncodingHandler = PyUnknownEncodingHandler;
|
capi->DefaultUnknownEncodingHandler = PyUnknownEncodingHandler;
|
||||||
#if XML_COMBINED_VERSION >= 20100
|
#if XML_COMBINED_VERSION >= 20100
|
||||||
capi.SetHashSalt = XML_SetHashSalt;
|
capi->SetHashSalt = XML_SetHashSalt;
|
||||||
#else
|
#else
|
||||||
capi.SetHashSalt = NULL;
|
capi->SetHashSalt = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* export using capsule */
|
/* export using capsule */
|
||||||
PyObject *capi_object = PyCapsule_New(&capi, PyExpat_CAPSULE_NAME, NULL);
|
PyObject *capi_object = PyCapsule_New(capi, PyExpat_CAPSULE_NAME,
|
||||||
|
pyexpat_destructor);
|
||||||
if (capi_object == NULL) {
|
if (capi_object == NULL) {
|
||||||
|
PyMem_Free(capi);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,7 @@ is_typing_name(PyObject *obj, int num, ...)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
va_end(names);
|
||||||
if (!hit) {
|
if (!hit) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +185,6 @@ is_typing_name(PyObject *obj, int num, ...)
|
||||||
&& _PyUnicode_EqualToASCIIString(module, "typing");
|
&& _PyUnicode_EqualToASCIIString(module, "typing");
|
||||||
Py_DECREF(module);
|
Py_DECREF(module);
|
||||||
|
|
||||||
va_end(names);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue