summaryrefslogtreecommitdiff
path: root/Objects/memoryobject.c
AgeCommit message (Collapse)AuthorLines
2022-06-23gh-92888: Fix memoryview bad `__index__` use after free (GH-92946) (GH-93950)Ken Jin-19/+36
(cherry picked from commit 11190c4ad0d3722b8d263758ac802985131a5462) Co-authored-by: chilaxan <35645806+chilaxan@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <3659035+serhiy-storchaka@users.noreply.github.com>
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.
2020-09-08bpo-41732: add iterator to memoryview (GH-22119)dxflores-1/+107
2020-07-18bpo-41262: Convert memoryview to Argument Clinic. (GH-21421)Serhiy Storchaka-73/+74
2020-05-28bpo-40792: Make the result of PyNumber_Index() always having exact type int. ↵Serhiy Storchaka-6/+6
(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-04-15bpo-40268: Remove unused pycore_pymem.h includes (GH-19531)Victor Stinner-1/+0
2020-04-14bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)Victor Stinner-1/+0
2020-04-08bpo-40170: Add _PyIndex_Check() internal function (GH-19426)Victor Stinner-3/+5
Add _PyIndex_Check() function to the internal C API: fast inlined verson of PyIndex_Check(). Add Include/internal/pycore_abstract.h header file. Replace PyIndex_Check() with _PyIndex_Check() in C files of Objects and Python subdirectories.
2020-02-24Give proper credits for the memoryview implementation. (#18626)Stefan Krah-1/+11
2020-02-11closes bpo-39605: Fix some casts to not cast away const. (GH-18453)Andy Lester-4/+4
gcc -Wcast-qual turns up a number of instances of casting away constness of pointers. Some of these can be safely modified, by either: Adding the const to the type cast, as in: - return _PyUnicode_FromUCS1((unsigned char*)s, size); + return _PyUnicode_FromUCS1((const unsigned char*)s, size); or, Removing the cast entirely, because it's not necessary (but probably was at one time), as in: - PyDTrace_FUNCTION_ENTRY((char *)filename, (char *)funcname, lineno); + PyDTrace_FUNCTION_ENTRY(filename, funcname, lineno); These changes will not change code, but they will make it much easier to check for errors in consts
2020-02-11bpo-39245: Switch to public API for Vectorcall (GH-18460)Petr Viktorin-2/+2
The bulk of this patch was generated automatically with: for name in \ PyObject_Vectorcall \ Py_TPFLAGS_HAVE_VECTORCALL \ PyObject_VectorcallMethod \ PyVectorcall_Function \ PyObject_CallOneArg \ PyObject_CallMethodNoArgs \ PyObject_CallMethodOneArg \ ; do echo $name git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g" done old=_PyObject_FastCallDict new=PyObject_VectorcallDict git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g" and then cleaned up: - Revert changes to in docs & news - Revert changes to backcompat defines in headers - Nudge misaligned comments
2020-01-27bpo-38631: Avoid Py_FatalError() in _memory_release() (GH-18214)Victor Stinner-1/+2
If the export count is negative, _memory_release() now raises a SystemError and returns -1, rather than calling Py_FatalError() which aborts the process.
2019-07-04bpo-37483: add _PyObject_CallOneArg() function (#14558)Jeroen Demeyer-2/+2
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-29bpo-22385: Support output separators in hex methods. (#13578)Gregory P. Smith-8/+37
* bpo-22385: Support output separators in hex methods. Also in binascii.hexlify aka b2a_hex. The underlying implementation behind all hex generation in CPython uses the same pystrhex.c implementation. This adds support to bytes, bytearray, and memoryview objects. The binascii module functions exist rather than being slated for deprecation because they return bytes rather than requiring an intermediate step through a str object. This change was inspired by MicroPython which supports sep in its binascii implementation (and does not yet support the .hex methods). https://bugs.python.org/issue22385
2019-03-05bpo-33012: Fix compilation warnings in memoryobject.c and ↵Stéphane Wirtel-1/+1
_collectionsmodule.c (GH-12179) Cast function pointers to (void(*)(void)) before casting to (PyCFunction) to make "warning: cast between incompatible function types" false alarm quiet.
2019-02-02bpo-35845: Add order={'C', 'F', 'A'} parameter to memoryview.tobytes(). (#11730)Stefan Krah-9/+35
2018-11-27bpo-33029: Fix signatures of getter and setter functions. (GH-10746)Serhiy Storchaka-9/+9
Fix also return type for few other functions (clear, releasebuffer).
2018-11-27bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka-1/+1
Fix invalid function cast warnings with gcc 8 for method conventions different from METH_NOARGS, METH_O and METH_VARARGS excluding Argument Clinic generated code.
2018-11-21bpo-35081: Add Include/internal/pycore_object.h (GH-10640)Victor Stinner-0/+1
Move _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() from Include/objimpl.h to Include/internal/pycore_object.h.
2018-11-12bpo-35081: Rename internal headers (GH-10275)Victor Stinner-2/+2
Rename Include/internal/ headers: * pycore_hash.h -> pycore_pyhash.h * pycore_lifecycle.h -> pycore_pylifecycle.h * pycore_mem.h -> pycore_pymem.h * pycore_state.h -> pycore_pystate.h Add missing headers to Makefile.pre.in and PCbuild: * pycore_condvar.h. * pycore_hamt.h * pycore_pyhash.h
2018-11-01bpo-35081: Add pycore_ prefix to internal header files (GH-10263)Victor Stinner-2/+2
* Rename Include/internal/ header files: * pyatomic.h -> pycore_atomic.h * ceval.h -> pycore_ceval.h * condvar.h -> pycore_condvar.h * context.h -> pycore_context.h * pygetopt.h -> pycore_getopt.h * gil.h -> pycore_gil.h * hamt.h -> pycore_hamt.h * hash.h -> pycore_hash.h * mem.h -> pycore_mem.h * pystate.h -> pycore_state.h * warnings.h -> pycore_warnings.h * PCbuild project, Makefile.pre.in, Modules/Setup: add the Include/internal/ directory to the search paths of header files. * Update includes. For example, replace #include "internal/mem.h" with #include "pycore_mem.h".
2018-04-14bpo-33176: Add a toreadonly() method to memoryviews. (GH-6466)Antoine Pitrou-0/+19
2017-09-07bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow-0/+2
* group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
2017-04-08Expand the PySlice_GetIndicesEx macro. (#1023)Serhiy Storchaka-2/+2
2017-03-21bpo-29865: Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types. ↵Serhiy Storchaka-1/+1
(#748)
2016-12-30Merge 3.5.Stefan Krah-1/+1
2016-12-30Issue #29111: Fix memoryview signature.Stefan Krah-1/+1
2016-09-08use static inline instead of Py_LOCAL_INLINEBenjamin Peterson-16/+16
2016-09-07require C99 boolBenjamin Peterson-20/+0
2016-09-06replace PY_LONG_LONG with long longBenjamin Peterson-17/+17
2016-09-05require a long long data type (closes #27961)Benjamin Peterson-12/+0
2015-12-25Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka-2/+2
private functions.
2015-11-10Fix Visual Studio warning.Stefan Krah-1/+1
2015-11-10Iaaue #25598: Fix memory_hex from #9951 for non-contiguous buffers.Stefan Krah-1/+16
2015-08-08Issue #15944: memoryview: Allow arbitrary formats when casting to bytes.Stefan Krah-8/+2
Original patch by Martin Panter.
2015-04-25Implements issue #9951: Adds a hex() method to bytes, bytearray, & memoryview.Gregory P. Smith-0/+14
Also updates a few internal implementations of the same thing to use the new built-in code. Contributed by Arnon Yaari.
2015-03-19Issue #23632: Memoryviews now allow tuple indexing (including for ↵Antoine Pitrou-29/+120
multi-dimensional memoryviews).
2015-03-18Removed unintentional trailing spaces in non-external and non-generated C files.Serhiy Storchaka-3/+3
2015-01-29Closes #22668: Merge from 3.4.Stefan Krah-4/+52
2015-01-29Issue #22668: Ensure that format strings survive slicing after casting.Stefan Krah-4/+52
2014-10-05#16518: Bring error messages in harmony with docs ("bytes-like object")R David Murray-1/+1
Some time ago we changed the docs to consistently use the term 'bytes-like object' in all the contexts where bytes, bytearray, memoryview, etc are used. This patch (by Ezio Melotti) completes that work by changing the error messages that previously reported that certain types did "not support the buffer interface" to instead say that a bytes-like object is required. (The glossary entry for bytes-like object references the discussion of the buffer protocol in the docs.)
2014-05-18Issue #20186: memoryobject.c: add function signatures.Stefan Krah-5/+6
2014-05-14Issue #21490: Add new C macros: Py_ABS() and Py_STRINGIFY()Victor Stinner-5/+2
Keep _Py_STRINGIZE() in PC/pyconfig.h to not introduce a dependency between pyconfig.h and pymacros.h.
2013-11-20ssue #19183: Implement PEP 456 'secure and interchangeable hash algorithm'.Christian Heimes-1/+1
Python now uses SipHash24 on all major platforms.
2013-10-03Issue #19014: memoryview.cast() is now allowed on zero-length views.Antoine Pitrou-1/+1
2013-10-03Issue #19014: memoryview.cast() is now allowed on zero-length views.Antoine Pitrou-1/+1
2013-10-02Close #19078: memoryview now supports reversedNick Coghlan-1/+1
Patch by Claudiu Popa
2013-02-19Fix error messages.Stefan Krah-2/+3
2012-11-02Issue #15814: Use hash function that is compatible with the equalityStefan Krah-0/+8
definition from #15573.