| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -121,6 +121,14 @@ Python 3.13 | |||
| 121 | 121 | ||
| 122 | 122 | See `PyUnicode_EqualToUTF8AndSize() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicode_EqualToUTF8AndSize>`__. | |
| 123 | 123 | ||
| 124 | + .. c:function:: int PyList_Extend(PyObject *list, PyObject *iterable) | ||
| 125 | + | ||
| 126 | + See `PyList_Extend() documentation <https://docs.python.org/dev/c-api/list.html#c.PyList_Extend>`__. | ||
| 127 | + | ||
| 128 | + .. c:function:: int PyList_Clear(PyObject *list) | ||
| 129 | + | ||
| 130 | + See `PyList_Clear() documentation <https://docs.python.org/dev/c-api/list.html#c.PyList_Clear>`__. | ||
| 131 | + | ||
| 124 | 132 | ||
| 125 | 133 | Python 3.12 | |
| 126 | 134 | ----------- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,11 @@ | |||
| 1 | 1 | Changelog | |
| 2 | 2 | ========= | |
| 3 | 3 | ||
| 4 | + * 2023-11-13: Add functions: | ||
| 5 | + | ||
| 6 | + * ``PyList_Extend()`` | ||
| 7 | + * ``PyList_Clear()`` | ||
| 8 | + | ||
| 4 | 9 | * 2023-10-04: Add functions: | |
| 5 | 10 | ||
| 6 | 11 | * ``PyUnicode_EqualToUTF8()`` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1013,6 +1013,21 @@ PyUnicode_EqualToUTF8(PyObject *unicode, const char *str) | |||
| 1013 | 1013 | #endif | |
| 1014 | 1014 | ||
| 1015 | 1015 | ||
| 1016 | + // gh-111138 added PyList_Extend() and PyList_Clear() to Python 3.13.0a2 | ||
| 1017 | + #if PY_VERSION_HEX < 0x030D00A2 | ||
| 1018 | + static inline int | ||
| 1019 | + PyList_Extend(PyObject *list, PyObject *iterable) | ||
| 1020 | + { | ||
| 1021 | + return PyList_SetSlice(list, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, iterable); | ||
| 1022 | + } | ||
| 1023 | + | ||
| 1024 | + static inline int | ||
| 1025 | + PyList_Clear(PyObject *list) | ||
| 1026 | + { | ||
| 1027 | + return PyList_SetSlice(list, 0, PY_SSIZE_T_MAX, NULL); | ||
| 1028 | + } | ||
| 1029 | + #endif | ||
| 1030 | + | ||
| 1016 | 1031 | #ifdef __cplusplus | |
| 1017 | 1032 | } | |
| 1018 | 1033 | #endif | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1395,6 +1395,33 @@ test_unicode(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) | |||
| 1395 | 1395 | } | |
| 1396 | 1396 | ||
| 1397 | 1397 | ||
| 1398 | + static PyObject * | ||
| 1399 | + test_list(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) | ||
| 1400 | + { | ||
| 1401 | + PyObject *list = PyList_New(0); | ||
| 1402 | + if (list == NULL) { | ||
| 1403 | + return NULL; | ||
| 1404 | + } | ||
| 1405 | + | ||
| 1406 | + PyObject *abc = PyUnicode_FromString("abc"); | ||
| 1407 | + if (abc == NULL) { | ||
| 1408 | + return NULL; | ||
| 1409 | + } | ||
| 1410 | + | ||
| 1411 | + // test PyList_Extend() | ||
| 1412 | + assert(PyList_Extend(list, abc) == 0); | ||
| 1413 | + Py_DECREF(abc); | ||
| 1414 | + assert(PyList_GET_SIZE(list) == 3); | ||
| 1415 | + | ||
| 1416 | + // test PyList_Clear() | ||
| 1417 | + assert(PyList_Clear(list) == 0); | ||
| 1418 | + assert(PyList_GET_SIZE(list) == 0); | ||
| 1419 | + | ||
| 1420 | + Py_DECREF(list); | ||
| 1421 | + Py_RETURN_NONE; | ||
| 1422 | + } | ||
| 1423 | + | ||
| 1424 | + | ||
| 1398 | 1425 | static struct PyMethodDef methods[] = { | |
| 1399 | 1426 | {"test_object", test_object, METH_NOARGS, _Py_NULL}, | |
| 1400 | 1427 | {"test_py_is", test_py_is, METH_NOARGS, _Py_NULL}, | |
@@ -1425,6 +1452,7 @@ static struct PyMethodDef methods[] = { | |||
| 1425 | 1452 | {"test_managed_dict", test_managed_dict, METH_NOARGS, _Py_NULL}, | |
| 1426 | 1453 | #endif | |
| 1427 | 1454 | {"test_unicode", test_unicode, METH_NOARGS, _Py_NULL}, | |
| 1455 | + {"test_list", test_list, METH_NOARGS, _Py_NULL}, | ||
| 1428 | 1456 | {_Py_NULL, _Py_NULL, 0, _Py_NULL} | |
| 1429 | 1457 | }; | |
| 1430 | 1458 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments