| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,9 @@ Core and Builtins | |||
| 26 | 26 | Library | |
| 27 | 27 | ------- | |
| 28 | 28 | ||
| 29 | + - Issue #7063: Remove dead code from the "array" module's slice handling. | ||
| 30 | + Patch by Chuck. | ||
| 31 | + | ||
| 29 | 32 | - Issue #27130: In the "zlib" module, fix handling of large buffers | |
| 30 | 33 | (typically 4 GiB) when compressing and decompressing. Previously, inputs | |
| 31 | 34 | were limited to 4 GiB, and compression and decompression operations did not | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -846,37 +846,10 @@ array_repeat(arrayobject *a, Py_ssize_t n) | |||
| 846 | 846 | } | |
| 847 | 847 | ||
| 848 | 848 | static int | |
| 849 | - array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) | ||
| 849 | + array_del_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh) | ||
| 850 | 850 | { | |
| 851 | 851 | char *item; | |
| 852 | - Py_ssize_t n; /* Size of replacement array */ | ||
| 853 | 852 | Py_ssize_t d; /* Change in size */ | |
| 854 | - #define b ((arrayobject *)v) | ||
| 855 | - if (v == NULL) | ||
| 856 | - n = 0; | ||
| 857 | - else if (array_Check(v)) { | ||
| 858 | - n = Py_SIZE(b); | ||
| 859 | - if (a == b) { | ||
| 860 | - /* Special case "a[i:j] = a" -- copy b first */ | ||
| 861 | - int ret; | ||
| 862 | - v = array_slice(b, 0, n); | ||
| 863 | - if (!v) | ||
| 864 | - return -1; | ||
| 865 | - ret = array_ass_slice(a, ilow, ihigh, v); | ||
| 866 | - Py_DECREF(v); | ||
| 867 | - return ret; | ||
| 868 | - } | ||
| 869 | - if (b->ob_descr != a->ob_descr) { | ||
| 870 | - PyErr_BadArgument(); | ||
| 871 | - return -1; | ||
| 872 | - } | ||
| 873 | - } | ||
| 874 | - else { | ||
| 875 | - PyErr_Format(PyExc_TypeError, | ||
| 876 | - "can only assign array (not \"%.200s\") to array slice", | ||
| 877 | - Py_TYPE(v)->tp_name); | ||
| 878 | - return -1; | ||
| 879 | - } | ||
| 880 | 853 | if (ilow < 0) | |
| 881 | 854 | ilow = 0; | |
| 882 | 855 | else if (ilow > Py_SIZE(a)) | |
@@ -888,7 +861,7 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) | |||
| 888 | 861 | else if (ihigh > Py_SIZE(a)) | |
| 889 | 862 | ihigh = Py_SIZE(a); | |
| 890 | 863 | item = a->ob_item; | |
| 891 | - d = n - (ihigh-ilow); | ||
| 864 | + d = ihigh-ilow; | ||
| 892 | 865 | /* Issue #4509: If the array has exported buffers and the slice | |
| 893 | 866 | assignment would change the size of the array, fail early to make | |
| 894 | 867 | sure we don't modify it. */ | |
@@ -897,25 +870,14 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) | |||
| 897 | 870 | "cannot resize an array that is exporting buffers"); | |
| 898 | 871 | return -1; | |
| 899 | 872 | } | |
| 900 | - if (d < 0) { /* Delete -d items */ | ||
| 901 | - memmove(item + (ihigh+d)*a->ob_descr->itemsize, | ||
| 873 | + if (d > 0) { /* Delete d items */ | ||
| 874 | + memmove(item + (ihigh-d)*a->ob_descr->itemsize, | ||
| 902 | 875 | item + ihigh*a->ob_descr->itemsize, | |
| 903 | 876 | (Py_SIZE(a)-ihigh)*a->ob_descr->itemsize); | |
| 904 | - if (array_resize(a, Py_SIZE(a) + d) == -1) | ||
| 877 | + if (array_resize(a, Py_SIZE(a) - d) == -1) | ||
| 905 | 878 | return -1; | |
| 906 | 879 | } | |
| 907 | - else if (d > 0) { /* Insert d items */ | ||
| 908 | - if (array_resize(a, Py_SIZE(a) + d)) | ||
| 909 | - return -1; | ||
| 910 | - memmove(item + (ihigh+d)*a->ob_descr->itemsize, | ||
| 911 | - item + ihigh*a->ob_descr->itemsize, | ||
| 912 | - (Py_SIZE(a)-ihigh)*a->ob_descr->itemsize); | ||
| 913 | - } | ||
| 914 | - if (n > 0) | ||
| 915 | - memcpy(item + ilow*a->ob_descr->itemsize, b->ob_item, | ||
| 916 | - n*b->ob_descr->itemsize); | ||
| 917 | 880 | return 0; | |
| 918 | - #undef b | ||
| 919 | 881 | } | |
| 920 | 882 | ||
| 921 | 883 | static int | |
@@ -927,7 +889,7 @@ array_ass_item(arrayobject *a, Py_ssize_t i, PyObject *v) | |||
| 927 | 889 | return -1; | |
| 928 | 890 | } | |
| 929 | 891 | if (v == NULL) | |
| 930 | - return array_ass_slice(a, i, i+1, v); | ||
| 892 | + return array_del_slice(a, i, i+1); | ||
| 931 | 893 | return (*a->ob_descr->setitem)(a, i, v); | |
| 932 | 894 | } | |
| 933 | 895 | ||
@@ -1155,8 +1117,7 @@ array_array_remove(arrayobject *self, PyObject *v) | |||
| 1155 | 1117 | cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); | |
| 1156 | 1118 | Py_DECREF(selfi); | |
| 1157 | 1119 | if (cmp > 0) { | |
| 1158 | - if (array_ass_slice(self, i, i+1, | ||
| 1159 | - (PyObject *)NULL) != 0) | ||
| 1120 | + if (array_del_slice(self, i, i+1) != 0) | ||
| 1160 | 1121 | return NULL; | |
| 1161 | 1122 | Py_INCREF(Py_None); | |
| 1162 | 1123 | return Py_None; | |
@@ -1199,7 +1160,7 @@ array_array_pop_impl(arrayobject *self, Py_ssize_t i) | |||
| 1199 | 1160 | v = getarrayitem((PyObject *)self, i); | |
| 1200 | 1161 | if (v == NULL) | |
| 1201 | 1162 | return NULL; | |
| 1202 | - if (array_ass_slice(self, i, i+1, (PyObject *)NULL) != 0) { | ||
| 1163 | + if (array_del_slice(self, i, i+1) != 0) { | ||
| 1203 | 1164 | Py_DECREF(v); | |
| 1204 | 1165 | return NULL; | |
| 1205 | 1166 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments