summaryrefslogtreecommitdiff
path: root/Objects/dictobject.c
Commit message (Collapse)AuthorAgeFilesLines
...
* bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka2018-11-271-9/+9
| | | | | | 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.
* bpo-33012: Fix signatures of METH_NOARGS funstions. (GH-10736)Serhiy Storchaka2018-11-271-2/+2
|
* bpo-35081: Add Include/internal/pycore_object.h (GH-10640)Victor Stinner2018-11-211-0/+1
| | | | Move _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() from Include/objimpl.h to Include/internal/pycore_object.h.
* bpo-35230: dict: Remove some macros (GH-10513)INADA Naoki2018-11-141-42/+59
| | | | Remove _Py_REF_DEBUG_COMMA, DK_DEBUG_INCREF, and DK_DEBUG_DECREF. Convert DK_INCREF and DK_DECREF to static inline functions.
* bpo-35081: Rename internal headers (GH-10275)Victor Stinner2018-11-121-1/+1
| | | | | | | | | | | | | | 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
* bpo-33462: Add __reversed__ to dict and dict views (GH-6827)Rémi Lapeyre2018-11-061-5/+202
|
* bpo-35081: Add _PyThreadState_GET() internal macro (GH-10266)Victor Stinner2018-11-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | If Py_BUILD_CORE is defined, the PyThreadState_GET() macro access _PyRuntime which comes from the internal pycore_state.h header. Public headers must not require internal headers. Move PyThreadState_GET() and _PyInterpreterState_GET_UNSAFE() from Include/pystate.h to Include/internal/pycore_state.h, and rename PyThreadState_GET() to _PyThreadState_GET() there. The PyThreadState_GET() macro of pystate.h is now redefined when pycore_state.h is included, to use the fast _PyThreadState_GET(). Changes: * Add _PyThreadState_GET() macro * Replace "PyThreadState_GET()->interp" with _PyInterpreterState_GET_UNSAFE() * Replace PyThreadState_GET() with _PyThreadState_GET() in internal C files (compiled with Py_BUILD_CORE defined), but keep PyThreadState_GET() in the public header files. * _testcapimodule.c: replace PyThreadState_GET() with PyThreadState_Get(); the module is not compiled with Py_BUILD_CORE defined. * pycore_state.h now requires Py_BUILD_CORE to be defined.
* bpo-35081: Add pycore_ prefix to internal header files (GH-10263)Victor Stinner2018-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | * 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".
* bpo-35081: Cleanup pystate.c and pystate.h (GH-10240)Victor Stinner2018-10-301-2/+2
| | | | | | | | | | | | * Remove _PyThreadState_Current * Replace GET_TSTATE() with PyThreadState_GET() * Replace GET_INTERP_STATE() with _PyInterpreterState_GET_UNSAFE() * Replace direct access to _PyThreadState_Current with PyThreadState_GET() * Replace _PyThreadState_Current with _PyRuntime.gilstate.tstate_current * Rename SET_TSTATE() to _PyThreadState_SET(), name more consistent with _PyThreadState_GET() * Update outdated comments
* bpo-9263: _PyXXX_CheckConsistency() use _PyObject_ASSERT() (GH-10108)Victor Stinner2018-10-261-13/+17
| | | | | | | | | | Use _PyObject_ASSERT() in: * _PyDict_CheckConsistency() * _PyType_CheckConsistency() * _PyUnicode_CheckConsistency() _PyObject_ASSERT() dumps the faulty object if the assertion fails to help debugging.
* bpo-34573: Simplify __reduce__() of set and dict iterators. (GH-9050)Sergey Fedoseev2018-10-201-34/+4
| | | | Simplify the pickling of set and dictionary objects iterators by consuming the iterator into a list with PySequence_List.
* bpo-34320: Fix dict(o) didn't copy order of dict subclass (GH-8624)INADA Naoki2018-09-251-1/+3
| | | | | | | When dict subclass overrides order (`__iter__()`, `keys()`, and `items()`), `dict(o)` should use it instead of dict ordering. https://bugs.python.org/issue34320
* bpo-34042: Fix dict.copy() to maintain correct total refcount (GH-8119)Yury Selivanov2018-07-061-0/+7
|
* bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. ↵Siddhesh Poyarekar2018-04-291-16/+16
| | | | | | | | | (GH-6030) METH_NOARGS functions need only a single argument but they are cast into a PyCFunction, which takes two arguments. This triggers an invalid function cast warning in gcc8 due to the argument mismatch. Fix this by adding a dummy unused argument.
* Spelling fixes to docs, docstrings, and comments (GH-6374)Ville Skyttä2018-04-201-1/+1
|
* bpo-33312: Fix clang ubsan out of bounds warnings in dict. (GH-6537)Gregory P. Smith2018-04-191-15/+12
| | | | | | | | | | | | | | | | | | | | Fix clang ubsan (undefined behavior sanitizer) warnings in dictobject.c by adjusting how the internal struct _dictkeysobject shared keys structure is declared. This remains ABI compatible. We get rid of the union at the end of the struct being used for conveinence to avoid typecasting in favor of char[] variable length array at the end of a struct. This is known to clang to be used for variable sized objects and will not cause an undefined behavior problem. Similarly, char arrays do not have strict aliasing undefined behavior when cast. PEP-007 does not currently list variable length arrays (VLAs) as allowed in our subset of C99. If this turns out to be a problem, the fix to this is to change the char `dk_indices[]` into `dk_indices[1]` and restore the three size computation subtractions this change removes: `- Py_MEMBER_SIZE(PyDictKeysObject, dk_indices)` If this works as is I'll make a separate PR to update PEP-007.
* bpo-33205: dict: Change GROWTH_RATE to `used*3` (GH-6350)INADA Naoki2018-04-171-6/+5
|
* bpo-33199: Initialize ma_version_tag in PyDict_Copy (GH-6341)INADA Naoki2018-04-031-0/+1
|
* bpo-18533: Avoid RecursionError from repr() of recursive dictview (#4823)bennorth2018-01-261-4/+12
| | | | | | | | | | | | | | | | | dictview_repr(): Use a Py_ReprEnter() / Py_ReprLeave() pair to check for recursion, and produce "..." if so. test_recursive_repr(): Check for the string rather than a RecursionError. (Test cannot be any tighter as contents are implementation-dependent.) test_deeply_nested_repr(): Add new test, replacing the original test_recursive_repr(). It checks that a RecursionError is raised in the case of a non-recursive but deeply nested structure. (Very similar to what test_repr_deep() in test/test_dict.py does for a normal dict.) OrderedDictTests: Add new test case, to test behavior on OrderedDict instances containing their own values() or items().
* bpo-32571: Avoid raising unneeded AttributeError and silencing it in C code ↵Serhiy Storchaka2018-01-251-7/+6
| | | | | (GH-5222) Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
* bpo-31179: Make dict.copy() up to 5.5 times faster. (#3067)Yury Selivanov2018-01-221-0/+73
|
* bpo-31572: Get rid of _PyObject_HasAttrId() in dict and OrderedDict. (#3728)Serhiy Storchaka2017-11-111-4/+13
| | | | | Silence only AttributeError when get "key" and "items" attributes in the constructor and the update() method of dict and OrderedDict .
* Fix miscellaneous typos (#4275)luzpaz2017-11-051-1/+1
|
* bpo-31338 (#3374)Barry Warsaw2017-09-141-12/+6
| | | | | | | * Add Py_UNREACHABLE() as an alias to abort(). * Use Py_UNREACHABLE() instead of assert(0) * Convert more unreachable code to use Py_UNREACHABLE() * Document Py_UNREACHABLE() and a few other macros.
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-071-0/+1
| | | | | | | * 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).
* bpo-31095: fix potential crash during GC (GH-2974)INADA Naoki2017-08-241-0/+6
|
* bpo-29304: Simplify dict lookup functions (GH-2407)INADA Naoki2017-08-031-267/+130
| | | | * remove hashpos parameter from lookdict functions. * remove many duplicated code from lookdict functions.
* bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make (#1955)Serhiy Storchaka2017-07-031-2/+2
| | | | | the bare METH_FASTCALL be used for functions with positional-only parameters.
* bp-29304: Simplify dictobject.c (GH-2347)INADA Naoki2017-06-241-6/+6
| | | replace `(i << 2) + 1` with `i*5`
* bpo-29304: simplify lookdict_index() function. (GH-2273)INADA Naoki2017-06-231-15/+6
|
* bpo-27945: Fixed various segfaults with dict. (#1657)Serhiy Storchaka2017-05-201-25/+43
| | | | Based on patches by Duane Griffin and Tim Mitchell.
* bpo-29941: Assert fixes (#886)T. Wouters2017-03-311-1/+1
| | | | | | | | Make a non-Py_DEBUG, asserts-enabled build of CPython possible. This means making sure helper functions are defined when NDEBUG is not defined, not just when Py_DEBUG is defined. Also fix a division-by-zero in obmalloc.c that went unnoticed because in Py_DEBUG mode, elsize is never zero.
* Don't use Py_SIZE for dict object. (#747)Serhiy Storchaka2017-03-211-1/+1
|
* bpo-24274: fix erroneous comment in dictobject.c (GH-196)INADA Naoki2017-02-201-1/+2
| | | | lookdict_unicode() and lookdict_unicode_nodummy() may raise exception when key is not unicode.
* bpo-29438: fixed use-after-free in key sharing dict (#17)INADA Naoki2017-02-121-3/+7
|
* Issue #29311: Regenerate Argument Clinic.Serhiy Storchaka2017-02-041-1/+1
|
* Issues #29311, #29289: Fixed and improved docstrings for dict and OrderedDictSerhiy Storchaka2017-01-251-8/+10
| | | | methods.
* Issue #29311: Argument Clinic generates reasonable name for the parameter ↵Serhiy Storchaka2017-01-191-8/+9
| | | | "default".
* Add a note explaining why dict_update() doesn't use METH_FASTCALLVictor Stinner2017-01-191-0/+3
| | | | Issue #29312.
* dict.get() and dict.setdefault() now use ACVictor Stinner2017-01-191-24/+29
| | | | | | | | | | | Issue #29311: dict.get() and dict.setdefault() methods now use Argument Clinic to parse arguments. Their calling convention changes from METH_VARARGS to METH_FASTCALL which avoids the creation of a temporary tuple. The signature of docstrings is also enhanced. For example, get(...) becomes: get(self, key, default=None, /)
* Issue #28969: Fixed race condition in C implementation of functools.lru_cache.Serhiy Storchaka2017-01-121-8/+23
|\ | | | | | | | | KeyError could be raised when cached function with full cache was simultaneously called from differen threads with the same uncached arguments.
| * Issue #28969: Fixed race condition in C implementation of functools.lru_cache.Serhiy Storchaka2017-01-121-8/+23
| |\ | | | | | | | | | | | | KeyError could be raised when cached function with full cache was simultaneously called from differen threads with the same uncached arguments.
| | * Issue #28969: Fixed race condition in C implementation of functools.lru_cache.Serhiy Storchaka2017-01-121-8/+23
| | | | | | | | | | | | | | | KeyError could be raised when cached function with full cache was simultaneously called from differen threads with the same uncached arguments.
* | | Issue #28427: old keys should not remove new values fromAntoine Pitrou2016-12-271-16/+74
|\ \ \ | |/ / | | | | | | WeakValueDictionary when collecting from another thread.
| * | Issue #28427: old keys should not remove new values fromAntoine Pitrou2016-12-271-17/+74
| |\ \ | | |/ | | | | | | WeakValueDictionary when collecting from another thread.
| | * Issue #28427: old keys should not remove new values fromAntoine Pitrou2016-12-271-25/+56
| | | | | | | | | | | | WeakValueDictionary when collecting from another thread.
| | * Issue #28147: Fix a memory leak in split-table dictionariesINADA Naoki2016-12-201-6/+15
| | | | | | | | | | | | setattr() must not convert combined table into split table.
| | * Issue #28189: dictitems_contains no longer swallows compare errors.Raymond Hettinger2016-09-181-1/+1
| | | | | | | | | | | | (Patch by Xiang Zhang)
* | | Merge 3.6Victor Stinner2016-12-151-5/+22
|\ \ \ | |/ /
| * | Fix a memory leak in split-table dictionariesVictor Stinner2016-12-151-5/+22
| | | | | | | | | | | | | | | | | | | | | Issue #28147: Fix a memory leak in split-table dictionaries: setattr() must not convert combined table into split table. Patch written by INADA Naoki.