summaryrefslogtreecommitdiff
path: root/Modules/arraymodule.c
AgeCommit message (Collapse)AuthorLines
2021-09-22[3.10] [codemod] Fix non-matching bracket pairs (GH-28473) (GH-28511)Łukasz Langa-2/+2
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 8f943ca25732d548cf9f0b0393ba8d582fb93e29) Co-authored-by: Mohamad Mansour <66031317+mohamadmansourX@users.noreply.github.com>
2021-06-17bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) ↵Miss Islington (bot)-1/+1
(GH-26766) * Make functools types immutable * Multibyte codec types are now immutable * pyexpat.xmlparser is now immutable * array.arrayiterator is now immutable * _thread types are now immutable * _csv types are now immutable * _queue.SimpleQueue is now immutable * mmap.mmap is now immutable * unicodedata.UCD is now immutable * sqlite3 types are now immutable * _lsprof.Profiler is now immutable * _overlapped.Overlapped is now immutable * _operator types are now immutable * winapi__overlapped.Overlapped is now immutable * _lzma types are now immutable * _bz2 types are now immutable * _dbm.dbm and _gdbm.gdbm are now immutable (cherry picked from commit 00710e6346fd2394aa020b2dfae170093effac98) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no> Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2021-05-25bpo-42972: Fully implement GC protocol for arraymodule types (GH-26114)Miss Islington (bot)-2/+11
(cherry picked from commit bd404ccac0d3e8358995ac0cbeec9373bb6c4d96) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2021-04-30bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types (GH-25748)Erlend Egeberg Aasland-1/+2
Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to the following types: * _dbm.dbm * _gdbm.gdbm * _multibytecodec.MultibyteCodec * _sre..SRE_Scanner * _thread._localdummy * _thread.lock * _winapi.Overlapped * array.arrayiterator * functools.KeyWrapper * functools._lru_list_elem * pyexpat.xmlparser * re.Match * re.Pattern * unicodedata.UCD * zlib.Compress * zlib.Decompress
2021-04-30bpo-43977: Use tp_flags for collection matching (GH-25723)Mark Shannon-1/+2
* Add Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING, add to all relevant standard builtin classes. * Set relevant flags on collections.abc.Sequence and Mapping. * Use flags in MATCH_SEQUENCE and MATCH_MAPPING opcodes. * Inherit Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING. * Add NEWS * Remove interpreter-state map_abc and seq_abc fields.
2021-04-29bpo-43908: Make array.array type immutable (GH-25696)Erlend Egeberg Aasland-1/+2
Co-authored-by: Victor Stinner <vstinner@python.org>
2021-04-22bpo-40137: Add pycore_moduleobject.h internal header (GH-25507)Victor Stinner-1/+2
Add pycore_moduleobject.h internal header file with static inline functions to access module members: * _PyModule_GetDict() * _PyModule_GetDef() * _PyModule_GetState() These functions don't check at runtime if their argument has a valid type and can be inlined even if Python is not built with LTO. _PyType_GetModuleByDef() uses _PyModule_GetDef(). Replace PyModule_GetState() with _PyModule_GetState() in the extension modules, considered as performance sensitive: * _abc * _functools * _operator * _pickle * _queue * _random * _sre * _struct * _thread * _winapi * array * posix The following extensions are now built with the Py_BUILD_CORE_MODULE macro defined, to be able to use the internal pycore_moduleobject.h header: _abc, array, _operator, _queue, _sre, _struct.
2021-04-03bpo-31956: Add start and stop parameters to array.index() (GH-25059)Zackery Spytz-5/+19
Co-Authored-By: Anders Lorentsen <Phaqui@gmail.com>
2021-01-03bpo-40077: Add traverse/clear/free to arraymodule (GH-24066)Erlend Egeberg Aasland-6/+33
2021-01-02bpo-40077: Convert arraymodule to use heap types and establish module state ↵Erlend Egeberg Aasland-157/+172
(GH-23124)
2020-12-01bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586)Victor Stinner-2/+2
No longer use deprecated aliases to functions: * Replace PyMem_MALLOC() with PyMem_Malloc() * Replace PyMem_REALLOC() with PyMem_Realloc() * Replace PyMem_FREE() with PyMem_Free() * Replace PyMem_Del() with PyMem_Free() * Replace PyMem_DEL() with PyMem_Free() Modify also the PyMem_DEL() macro to use directly PyMem_Free().
2020-07-05bpo-29727: Register array.array as a MutableSequence (GH-21338)Pablo Galindo-0/+20
2020-06-23bpo-41085: Fix array.array.index() on 64-bit Windows (GH-21071)WildCard65-1/+1
Fix integer overflow in the :meth:`array.array.index` method on 64-bit Windows for index larger than ``2**31``.
2020-05-28bpo-40792: Make the result of PyNumber_Index() always having exact type int. ↵Serhiy Storchaka-3/+3
(GH-20443) Previously, the result could have been an instance of a subclass of int. Also revert bpo-26202 and make attributes start, stop and step of the range object having exact type int. Add private function _PyNumber_Index() which preserves the old behavior of PyNumber_Index() for performance to use it in the conversion functions like PyLong_AsLong().
2020-05-27bpo-39573: Convert Py_REFCNT and Py_SIZE to functions (GH-20429)Victor Stinner-2/+2
Convert Py_REFCNT() and Py_SIZE() macros to static inline functions. They cannot be used as l-value anymore: use Py_SET_REFCNT() and Py_SET_SIZE() to set an object reference count and size. Replace &Py_SIZE(self) with &((PyVarObject*)self)->ob_size in arraymodule.c. This change is backward incompatible on purpose, to prepare the C API for an opaque PyObject structure.
2020-05-26bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)Serhiy Storchaka-14/+3
Only __index__ should be used to make integer conversions lossless.
2020-05-11bpo-36346: array: Don't use deprecated APIs (GH-19653)Inada Naoki-42/+40
* Py_UNICODE -> wchar_t * Py_UNICODE -> unicode in Argument Clinic * PyUnicode_AsUnicode -> PyUnicode_AsWideCharString * Don't use "u#" format. Co-authored-by: Victor Stinner <vstinner@python.org>
2020-04-15bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner-1/+1
If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
2020-03-04bpo-39770, array module: Remove unnecessary descriptor counting (GH-18675)Andy Lester-5/+0
2020-02-17bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)Dong-hee Na-1/+1
2020-02-07bpo-39573: Use Py_SET_SIZE() function (GH-18402)Victor Stinner-5/+5
Replace direct acccess to PyVarObject.ob_size with usage of the Py_SET_SIZE() function.
2020-02-07bpo-39573: Add Py_SET_TYPE() function (GH-18394)Victor Stinner-1/+1
Add Py_SET_TYPE() function to set the type of an object.
2019-12-09bpo-38916: array.array: remove fromstring() and tostring() (GH-17487)Victor Stinner-41/+0
array.array: Remove tostring() and fromstring() methods. They were aliases to tobytes() and frombytes(), deprecated since Python 3.2.
2019-11-15bpo-38677: Fix arraymodule error handling in module initialization. (GH-17039)Marco Paolini-8/+12
2019-10-21bpo-38465: Convert the type of exports counters to Py_ssize_t. (GH-16746)Hai Shi-1/+1
2019-07-11Remove redundant check from arraymodule b_getitem (GH-14676)Disconnect3d-3/+1
The `arraymodule`'s `b_getitem` function returns a `PyLong` converted from `arrayobject`'s array, by dereferencing a pointer to `char`. When the `char` type is `signed char`, the `if (x >= 128) x -= 256;` comparison/code is redundant because a `signed char` will have a value of `[-128, 127]` and so `x` will never be greater or equal than 128. This check was indeed needed for situations where a given compiler would assume `char` being `unsigned char` which would make `x` in `[0, 256]` range. However, the check can be removed if we cast the `ob_item` into a signed char pointer (`signed char*`) instead of `char*`. This PR/commit introduces this change.
2019-07-11bpo-37547: add _PyObject_CallMethodOneArg (GH-14685)Jeroen Demeyer-1/+1
2019-05-30bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer-4/+4
(GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
2019-05-23bpo-36842: Implement PEP 578 (GH-12613)Steve Dower-0/+5
Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
2019-05-17bpo-36946: Fix possible signed integer overflow when handling slices. (GH-13375)Zackery Spytz-2/+4
The final addition (cur += step) may overflow, so use size_t for "cur". "cur" is always positive (even for negative steps), so it is safe to use size_t here. Co-Authored-By: Martin Panter <vadmium+py@gmail.com>
2019-03-20bpo-36285: Fix integer overflow in the array module. (GH-12317)sth-4/+4
2019-02-25bpo-36048: Use __index__() instead of __int__() for implicit conversion if ↵Serhiy Storchaka-1/+1
available. (GH-11952) Deprecate using the __int__() method in implicit conversions of Python numbers to C integers.
2018-12-14bpo-35489: Use "const Py_UNICODE *" for the Py_UNICODE converter in AC. ↵Serhiy Storchaka-2/+2
(GH-11150)
2018-12-11bpo-35444: Unify and optimize the helper for getting a builtin object. ↵Serhiy Storchaka-1/+2
(GH-11047) This speeds up pickling of some iterators. This fixes also error handling in pickling methods when fail to look up builtin "getattr".
2018-12-08bpo-35441: Remove dead and buggy code related to PyList_SetItem(). (GH-11033)Zackery Spytz-3/+8
In _localemodule.c and selectmodule.c, remove dead code that would cause double decrefs if run. In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases where a new list is populated and there is no possibility of an error. In addition, check if the list changed size in the loop in array_array_fromlist().
2018-02-02bpo-32747: Remove trailing spaces in docstrings. (GH-5491)oldk-17/+17
2018-01-25 bpo-32571: Avoid raising unneeded AttributeError and silencing it in C code ↵Serhiy Storchaka-4/+3
(GH-5222) Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
2017-11-14bpo-32020: arraymodule: Correct missing Py_DECREF in failure case of ↵Mat M-1/+3
make_array() (#4391)
2017-09-21bpo-27541: Reprs of subclasses of some classes now contain actual type name. ↵Serhiy Storchaka-2/+4
(#3631) Affected classes are bytearray, array, deque, defaultdict, count and repeat.
2017-08-17bpo-24700: Add a fast path for comparing array.array of equal type (#3009)Adrian Wielgosik-15/+66
2017-06-08bpo-30592: Fixed error messages for some builtins. (#1996)Serhiy Storchaka-1/+1
Error messages when pass keyword arguments to some builtins that don't support keyword arguments contained double parenthesis: "()()". The regression was introduced by bpo-30534.
2017-05-29Change error message for array methods to use 'array' instead of 'list'. (#1853)Jim Fasarakis-Hilliard-2/+2
2017-04-08Expand the PySlice_GetIndicesEx macro. (#1023)Serhiy Storchaka-5/+6
2017-03-29bpo-29932: Fix small error message typos in arraymodule.c (GH-888)Sylvain-3/+3
2017-03-09bpo-28298: make array 'Q', 'L' and 'I' accept big intables as elements (#570)orenmn-46/+62
2017-01-23Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE whereverSerhiy Storchaka-16/+8
possible. Patch is writen with Coccinelle.
2016-12-09Use _PyObject_CallMethodIdObjArgs()Victor Stinner-1/+1
Issue #28915: Replace _PyObject_CallMethodId() with _PyObject_CallMethodIdObjArgs() in various modules when the format string was only made of "O" formats, PyObject* arguments. _PyObject_CallMethodIdObjArgs() avoids the creation of a temporary tuple and doesn't have to parse a format string.
2016-11-20Issue #19569: Compiler warnings are now emitted if use most of deprecatedSerhiy Storchaka-2/+2
functions.
2016-09-13Issue #28126: Replace Py_MEMCPY with memcpy(). Visual Studio can properly ↵Christian Heimes-2/+2
optimize memcpy().
2016-09-07Issue #27570: Merge null pointer fixes from 3.5Martin Panter-8/+16