summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* gh-96364: Fix text signatures of `__getitem__` for `list` and `dict` (GH-96365)Nikita Sobolev2022-09-092-2/+4
|
* gh-96352: Set AttributeError context in _PyObject_GenericGetAttrWithDict ↵philg3142022-09-081-0/+2
| | | | (#96353)
* gh-96143: Clear instruction cache after mprotect call (#96476)Pablo Galindo Salgado2022-09-081-4/+23
|
* GH-90699: use statically allocated interned strings in typeobject's slotdefs ↵Kumar Aditya2022-09-072-166/+106
| | | | (GH-94706)
* gh-95778: Correctly pre-check for int-to-str conversion (#96537)Mark Dickinson2022-09-041-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | Converting a large enough `int` to a decimal string raises `ValueError` as expected. However, the raise comes _after_ the quadratic-time base-conversion algorithm has run to completion. For effective DOS prevention, we need some kind of check before entering the quadratic-time loop. Oops! =) The quick fix: essentially we catch _most_ values that exceed the threshold up front. Those that slip through will still be on the small side (read: sufficiently fast), and will get caught by the existing check so that the limit remains exact. The justification for the current check. The C code check is: ```c max_str_digits / (3 * PyLong_SHIFT) <= (size_a - 11) / 10 ``` In GitHub markdown math-speak, writing $M$ for `max_str_digits`, $L$ for `PyLong_SHIFT` and $s$ for `size_a`, that check is: $$\left\lfloor\frac{M}{3L}\right\rfloor \le \left\lfloor\frac{s - 11}{10}\right\rfloor$$ From this it follows that $$\frac{M}{3L} < \frac{s-1}{10}$$ hence that $$\frac{L(s-1)}{M} > \frac{10}{3} > \log_2(10).$$ So $$2^{L(s-1)} > 10^M.$$ But our input integer $a$ satisfies $|a| \ge 2^{L(s-1)}$, so $|a|$ is larger than $10^M$. This shows that we don't accidentally capture anything _below_ the intended limit in the check. <!-- gh-issue-number: gh-95778 --> * Issue: gh-95778 <!-- /gh-issue-number --> Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
* GH-96458: Statically initialize utf8 representation of static strings (#96481)Kumar Aditya2022-09-031-33/+0
|
* gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96499)Gregory P. Smith2022-09-021-1/+44
| | | | | | | | | | | | | | | | Integer to and from text conversions via CPython's bignum `int` type is not safe against denial of service attacks due to malicious input. Very large input strings with hundred thousands of digits can consume several CPU seconds. This PR comes fresh from a pile of work done in our private PSRT security response team repo. Signed-off-by: Christian Heimes [Red Hat] <christian@python.org> Tons-of-polishing-up-by: Gregory P. Smith [Google] <greg@krypto.org> Reviews via the private PSRT repo via many others (see the NEWS entry in the PR). <!-- gh-issue-number: gh-95778 --> * Issue: gh-95778 <!-- /gh-issue-number --> I wrote up [a one pager for the release managers](https://docs.google.com/document/d/1KjuF_aXlzPUxTK4BMgezGJ2Pn7uevfX7g0_mvgHlL7Y/edit#). Much of that text wound up in the Issue. Backports PRs already exist. See the issue for links.
* gh-93554: Conditional jump opcodes only jump forward (GH-96318)Irit Katriel2022-09-011-16/+3
|
* gh-96455: update example in exception_handling_notes.txt to the 3.11RC ↵Irit Katriel2022-09-011-25/+28
| | | | bytecode (GH-96456)
* gh-96143: Add some comments and minor fixes missed in the original PR (#96433)Pablo Galindo Salgado2022-08-301-0/+11
| | | | | | | | | * gh-96132: Add some comments and minor fixes missed in the original PR * Update Doc/using/cmdline.rst Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-96143: Allow Linux perf profiler to see Python calls (GH-96123)Pablo Galindo Salgado2022-08-302-0/+529
| | | | | | | :warning: :warning: Note for reviewers, hackers and fellow systems/low-level/compiler engineers :warning: :warning: If you have a lot of experience with this kind of shenanigans and want to improve the **first** version, **please make a PR against my branch** or **reach out by email** or **suggest code changes directly on GitHub**. If you have any **refinements or optimizations** please, wait until the first version is merged before starting hacking or proposing those so we can keep this PR productive.
* GH-96237: Allow non-functions as reference-holder in frames. (GH-96238)Mark Shannon2022-08-251-3/+5
|
* GH-96068: Document object layout (GH-96069)Mark Shannon2022-08-235-0/+157
|
* GH-96187: Prevent _PyCode_GetExtra to return garbage for negative indexes ↵Pablo Galindo Salgado2022-08-231-1/+1
| | | | (GH-96188)
* GH-96075: move interned dict under runtime state (GH-96077)Kumar Aditya2022-08-221-14/+25
|
* gh-96046: Initialize ht_cached_keys in PyType_Ready() (GH-96047)Christian Heimes2022-08-221-9/+26
|
* GH-90997: Wrap yield from/await in a virtual try/except StopIteration (GH-96010)Brandt Bucher2022-08-191-20/+1
|
* gh-96017: Fix some compiler warnings (GH-96018)Christian Heimes2022-08-191-0/+2
| | | | | - "comparison of integers of different signs" in typeobject.c - only define static_builtin_index_is_set in DEBUG builds - only define recreate_gil with ifdef HAVE_FORK
* Remove dead code in _PyDict_GetItemHint and rename to _PyDict_LookupIndex ↵Matthias Görgens2022-08-181-41/+3
| | | | (GH-95948)
* GH-95589: Dont crash when subclassing extension classes with multiple ↵Mark Shannon2022-08-171-32/+13
| | | | | | | inheritance (GH-96028) * Treat tp_weakref and tp_dictoffset like other opaque slots for multiple inheritance. * Document Py_TPFLAGS_MANAGED_DICT and Py_TPFLAGS_MANAGED_WEAKREF in what's new.
* GH-93911: Specialize `LOAD_ATTR` for custom `__getattribute__` (GH-93988)Ken Jin2022-08-171-13/+13
|
* gh-96005: Handle WASI ENOTCAPABLE in getpath (GH-96006)Christian Heimes2022-08-161-0/+5
| | | | | | - On WASI `ENOTCAPABLE` is now mapped to `PermissionError`. - The `errno` modules exposes the new error number. - `getpath.py` now ignores `PermissionError` when it cannot open landmark files `pybuilddir.txt` and `pyenv.cfg`.
* GH-95245: Move weakreflist into the pre-header. (GH-95996)Mark Shannon2022-08-161-15/+28
|
* GH-95707: Fix uses of `Py_TPFLAGS_MANAGED_DICT` (GH-95854)Mark Shannon2022-08-152-17/+54
| | | | | | * Make sure that tp_dictoffset is correct with Py_TPFLAGS_MANAGED_DICT is set. * Avoid traversing managed dict twice when subclassing class with Py_TPFLAGS_MANAGED_DICT set.
* GH-95977: Speed up calling pure python descriptor __get__ with vectorcall ↵Kumar Aditya2022-08-141-1/+2
| | | | (gh-95978)
* gh-90928: Improve static initialization of keywords tuple in AC (#95907)Erlend E. Aasland2022-08-1315-746/+316
|
* gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code ↵Eric Snow2022-08-1120-63/+1602
| | | | | | | | | | | | | | | | (gh-95860) We only statically initialize for core code and builtin modules. Extension modules still create the tuple at runtime. We'll solve that part of interpreter isolation separately. This change includes generated code. The non-generated changes are in: * Tools/clinic/clinic.py * Python/getargs.c * Include/cpython/modsupport.h * Makefile.pre.in (re-generate global strings after running clinic) * very minor tweaks to Modules/_codecsmodule.c and Python/Python-tokenize.c All other changes are generated code (clinic, global strings).
* gh-95605: Fix `float(s)` error message when `s` contains only whitespace ↵Mark Dickinson2022-08-101-1/+8
| | | | | (GH-95665) This PR fixes the error message from float(s) in the case where s contains only whitespace.
* gh-95504: Fix negative numbers in PyUnicode_FromFormat (GH-95848)Petr Viktorin2022-08-101-6/+19
| | | Co-authored-by: philg314 <110174000+philg314@users.noreply.github.com>
* GH-92678: Document that you shouldn't be doing your own dictionary offset ↵Mark Shannon2022-08-091-1/+5
| | | | | | calculations. (GH-95598) Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
* gh-95781: More strict format string checking in PyUnicode_FromFormatV() ↵Serhiy Storchaka2022-08-081-23/+10
| | | | | | | | | (GH-95784) An unrecognized format character in PyUnicode_FromFormat() and PyUnicode_FromFormatV() now sets a SystemError. In previous versions it caused all the rest of the format string to be copied as-is to the result string, and any extra arguments discarded.
* gh-93274: Expose receiving vectorcall in the Limited API (GH-95717)Petr Viktorin2022-08-081-0/+8
|
* docs: Fix a few typos (#94899)Tim Gates2022-08-081-1/+1
| | | | | | - overriden => overridden - calcualation => calculation Signed-off-by: Tim Gates <tim.gates@iress.com>
* gh-94673: Add Per-Interpreter tp_subclasses for Static Builtin Types (gh-95301)Eric Snow2022-08-052-24/+94
|
* gh-94673: Recover Weaklist Lookup Performance (gh-95544)Eric Snow2022-08-041-4/+8
| | | gh-95302 seems to have introduced a small performance regression. Here we make some minor changes to recover that lost performance.
* gh-93274: Make vectorcall safe on mutable classes & inherit it by default ↵Petr Viktorin2022-08-041-5/+16
| | | | (#95437)
* gh-95388: Deprecate creating immutable types with mutable bases (GH-95533)Petr Viktorin2022-08-041-0/+26
|
* gh-94936: C getters: co_varnames, co_cellvars, co_freevars (#95008)Ken Jin2022-08-041-0/+18
|
* GH-92678: Fix tp_dictoffset inheritance. (GH-95596)Mark Shannon2022-08-031-3/+16
| | | | | | * Add test for inheriting explicit __dict__ and weakref. * Restore 3.10 behavior for multiple inheritance of C extension classes that store their dictionary at the end of the struct.
* GH-95150: Use position and exception tables for code hashing and equality ↵Brandt Bucher2022-08-011-1/+18
| | | | (GH-95509)
* GH-95245: Store object values and dict pointers in single tagged pointer. ↵Mark Shannon2022-08-013-165/+195
| | | | (GH-95278)
* gh-91146: More reduce allocation size of list from str.split/rsplit (gh-95493)Dong-hee Na2022-08-011-9/+22
| | | Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* gh-91146: Reduce allocation size of list from str.split()/rsplit() (gh-95473)Dong-hee Na2022-07-311-19/+20
|
* gh-94673: Add Per-Interpreter tp_weaklist for Static Builtin Types (#95302)Eric Snow2022-07-292-0/+25
| | | | | | | | | | | | | | | * Store tp_weaklist on the interpreter state for static builtin types. * Factor out _PyStaticType_GET_WEAKREFS_LISTPTR(). * Add _PyStaticType_ClearWeakRefs(). * Add a comment about how _PyStaticType_ClearWeakRefs() loops. * Document the change. * Update Doc/whatsnew/3.12.rst * Fix a typo.
* Fix Unicode doc and replace use of macro with PyMem_New function (GH-94088)Pamela Fox2022-07-281-1/+1
|
* gh-95369: add missing decref in error case of exception group's split (GH-95370)Irit Katriel2022-07-281-0/+1
|
* gh-95324: Emit a warning if an object doesn't call PyObject_GC_UnTrack ↵Pablo Galindo Salgado2022-07-272-2/+4
| | | | during deallocation in debug mode (#95325)
* gh-95005: Replace PyAccu with PyUnicodeWriter (gh-95006)Aivars Kalvāns2022-07-271-115/+0
|
* gh-94673: Add Per-Interpreter Storage for Static Builtin Types (#95255)Eric Snow2022-07-261-5/+106
| | | | | | | | | | | | | | This is the last precursor to storing tp_subclasses (and tp_weaklist) on the interpreter state for static builtin types. Here we add per-type storage on PyInterpreterState, but only for the static builtin types. This involves the following: * add PyInterpreterState.types * move PyInterpreterState.type_cache to it * add a "num_builtins_initialized" field * add a "builtins" field (a static array big enough for all the static builtin types) * add _PyStaticType_GetState() to look up a static builtin type's state * (temporarily) add PyTypeObject.tp_static_builtin_index (to hold the type's index into PyInterpreterState.types.builtins) We will be eliminating tp_static_builtin_index in a later change.
* gh-91247: Use memcpy for list and tuple repeat (#91482)Pieter Eendebak2022-07-262-65/+49
| | | | | | | * Add _Py_memory_repeat function to pycore_list * Add _Py_RefcntAdd function to pycore_object * Use the new functions in tuplerepeat, list_repeat, and list_inplace_repeat