Commit c961d61
committed
gh-153419: Fix several issues around bytearray __init__
Introduce a bytearray_new function to ensure that
ob_bytes_object is always set on a bytearray.
Resizing a bytearray to 0 length explicitly sets
the ob_bytes_object to the empty constant immortal.
Add a check in the 'bytearray init from string'
fast path to ensure there are no active exports.
This fixes asserts/crashes on the following:
- bytearray(1).__init__()
- bytearray().__new__(bytearray).append(1)
- a = bytearray(); b = memoryview(a); a.__init__('x', 'ascii')1 parent 33678dc commit c961d61
3 files changed
Lines changed: 78 additions & 13 deletions
File tree
- Lib/test
- Misc/NEWS.d/next/Core_and_Builtins
- Objects
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1860 | 1860 | | |
1861 | 1861 | | |
1862 | 1862 | | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
1863 | 1911 | | |
1864 | 1912 | | |
1865 | 1913 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
239 | 247 | | |
240 | 248 | | |
241 | 249 | | |
| |||
902 | 910 | | |
903 | 911 | | |
904 | 912 | | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
905 | 926 | | |
906 | 927 | | |
907 | 928 | | |
| |||
920 | 941 | | |
921 | 942 | | |
922 | 943 | | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | 944 | | |
931 | | - | |
| 945 | + | |
932 | 946 | | |
933 | 947 | | |
934 | 948 | | |
935 | 949 | | |
936 | | - | |
937 | 950 | | |
938 | | - | |
939 | 951 | | |
940 | 952 | | |
941 | 953 | | |
| |||
963 | 975 | | |
964 | 976 | | |
965 | 977 | | |
966 | | - | |
967 | | - | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
968 | 983 | | |
969 | 984 | | |
970 | 985 | | |
| |||
2937 | 2952 | | |
2938 | 2953 | | |
2939 | 2954 | | |
2940 | | - | |
| 2955 | + | |
2941 | 2956 | | |
2942 | 2957 | | |
2943 | 2958 | | |
| |||
0 commit comments