| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-17765)
* [3.7] bpo-38588: Fix possible crashes in dict and list when calling PyObject_RichCompareBool (GH-17734)
Take strong references before calling PyObject_RichCompareBool to protect against the case
where the object dies during the call..
(cherry picked from commit 2d5bf568eaa5059402ccce9ba5a366986ba27c8a)
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* methane's suggestion
methane's suggestion
Co-Authored-By: Inada Naoki <songofacandy@gmail.com>
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
|
| |
|
|
|
| |
(cherry picked from commit 359143c68659d165f52320d368667e0eff279dc5)
Co-authored-by: dalgarno <32097481+dalgarno@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
| |
When dict subclass overrides order (`__iter__()`, `keys()`, and `items()`), `dict(o)`
should use it instead of dict ordering.
https://bugs.python.org/issue34320
(cherry picked from commit 2aaf98c16ae3070378de523a173e29644037d8bd)
Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
|
| |
|
|
|
| |
(cherry picked from commit 0b75228700e0077d8bf2636e74733389514b4b2f)
Co-authored-by: Yury Selivanov <yury@magic.io>
|
| |
|
|
|
| |
(cherry picked from commit 61f82e0e337f971da57f8f513abfe693edf95aa5)
Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
(cherry picked from commit 397f1b28c4a12e3b3ed59a89599eabc457412649)
|
| |
|
|
|
| |
(cherry picked from commit 5fbc511f56688654a05b9eba23d140318bb9b2d5)
Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
|
| |
|
|
|
| |
(cherry picked from commit d1c82c5cc7be0c21dddf86fd19c1702f6218459b)
Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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().
|
| |
|
|
|
| |
(GH-5222)
Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
|
| | |
|
| |
|
|
|
| |
Silence only AttributeError when get "key" and "items" attributes in
the constructor and the update() method of dict and OrderedDict .
|
| | |
|
| |
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
|
| |
* 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).
|
| | |
|
| |
|
|
| |
* remove hashpos parameter from lookdict functions.
* remove many duplicated code from lookdict functions.
|
| |
|
|
|
| |
the bare METH_FASTCALL be used for functions with positional-only
parameters.
|
| |
|
| |
replace `(i << 2) + 1` with `i*5`
|
| | |
|
| |
|
|
| |
Based on patches by Duane Griffin and Tim Mitchell.
|
| |
|
|
|
|
|
|
| |
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.
|
| | |
|
| |
|
|
| |
lookdict_unicode() and lookdict_unicode_nodummy() may raise exception
when key is not unicode.
|
| | |
|
| | |
|
| |
|
|
| |
methods.
|
| |
|
|
| |
"default".
|
| |
|
|
| |
Issue #29312.
|
| |
|
|
|
|
|
|
|
|
|
| |
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, /)
|
| |\
| |
| |
| |
| | |
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
|
| | |\
| | |
| | |
| | |
| | | |
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
|
| | | |
| | |
| | |
| | |
| | | |
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
|
| |\ \ \
| |/ /
| | |
| | | |
WeakValueDictionary when collecting from another thread.
|
| | |\ \
| | |/
| | |
| | | |
WeakValueDictionary when collecting from another thread.
|
| | | |
| | |
| | |
| | | |
WeakValueDictionary when collecting from another thread.
|
| | | |
| | |
| | |
| | | |
setattr() must not convert combined table into split table.
|
| | | |
| | |
| | |
| | | |
(Patch by Xiang Zhang)
|
| |\ \ \
| |/ / |
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | | |
Issue #28147: Fix a memory leak in split-table dictionaries: setattr() must not
convert combined table into split table.
Patch written by INADA Naoki.
|
| | | |
| | |
| | |
| | | |
Improve speed of dict literal with constant keys up to 30%.
|
| | | | |
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | | |
Replace:
PyObject_CallObject(callable, NULL)
with:
_PyObject_CallNoArg(callable)
|
| | | |
| | |
| | |
| | |
| | |
| | | |
Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like
_PyObject_CallArg1() uses more stack memory than
PyObject_CallFunctionObjArgs().
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
* PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func)
* PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg)
PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires
extra work to "parse" C arguments to build a C array of PyObject*.
_PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate
memory on the C stack.
This change is part of the fastcall project. The change on listsort() is
related to the issue #23507.
|
| | | |
| | |
| | |
| | | |
Improve speed of dict literal with constant keys up to 30%.
|
| | | |
| | |
| | |
| | | |
It's common to see these functions in the top 3 of "perf report".
|
| | | |
| | |
| | |
| | |
| | | |
It seems like _PyThreadState_UncheckedGet() is not inlined as expected, even
when using gcc -O3.
|
| | | | |
|
| |\ \ \
| |/ /
| | |
| | | |
PyDict_GetItemWithError(). Patch by Xiang Zhang.
|