summaryrefslogtreecommitdiff
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* [3.8] closes bpo-39630: Update pointers to string literals to be const char ↵Benjamin Peterson2020-02-131-2/+2
| | | | | | | | *. (GH-18511) (cherry picked from commit 7386a70746cf9aaf2d95db75d9201fb124f085df) Co-authored-by: Andy Lester <andy@petdance.com>
* [3.8] bpo-39606: allow closing async generators that are already closed ↵Miss Islington (bot)2020-02-131-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-18475) (GH-18501) The fix for [bpo-39386](https://bugs.python.org/issue39386) attempted to make it so you couldn't reuse a agen.aclose() coroutine object. It accidentally also prevented you from calling aclose() at all on an async generator that was already closed or exhausted. This commit fixes it so we're only blocking the actually illegal cases, while allowing the legal cases. The new tests failed before this patch. Also confirmed that this fixes the test failures we were seeing in Trio with Python dev builds: https://github.com/python-trio/trio/pull/1396 https://bugs.python.org/issue39606 (cherry picked from commit 925dc7fb1d0db85dc137afa4cd14211bf0d67414) Co-authored-by: Nathaniel J. Smith <njs@pobox.com> https://bugs.python.org/issue39606 Automerge-Triggered-By: @njsmith
* bpo-39605: Remove a cast that causes a warning. (GH-18473)Miss Islington (bot)2020-02-111-1/+1
| | | | | (cherry picked from commit 95905ce0f41fd42eb1ef60ddb83f057401c3d52f) Co-authored-by: Benjamin Peterson <benjamin@python.org>
* closes bpo-39605: Fix some casts to not cast away const. (GH-18453)Miss Islington (bot)2020-02-116-31/+31
| | | | | | | | | | | | | | | | | | 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 (cherry picked from commit e6be9b59a911626d6597fe148c32f0342bd2bd24) Co-authored-by: Andy Lester <andy@petdance.com>
* Fixes in sorting descriptions (GH-18317)Miss Islington (bot)2020-02-031-8/+8
| | | | | | | | Improvements in listsort.txt and a comment in sortperf.py. Automerge-Triggered-By: @csabella (cherry picked from commit 24e5ad4689de9adc8e4a7d8c08fe400dcea668e6) Co-authored-by: Stefan Pochmann <stefan.pochmann@gmail.com>
* bpo-39425: Fix list.count performance regression (GH-18119) (GH-18120)Miss Islington (bot)2020-01-221-0/+4
| | | | | | | | | | | https://bugs.python.org/issue39425 Automerge-Triggered-By: @pablogsal (cherry picked from commit 14d80d0b605d8b148e14458e4c1853a940071462) Co-authored-by: Dong-hee Na <donghee.na92@gmail.com> Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* closes bpo-39415: Remove unused codes from longobject.c complexobject.c ↵Miss Islington (bot)2020-01-213-68/+0
| | | | | | | floatobject.c. (GH-18105) (cherry picked from commit 0d5eac8c327251f8edde5261cee43975d81311f6) Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* bpo-39386: Prevent double awaiting of async iterator (GH-18081)Miss Islington (bot)2020-01-201-4/+12
| | | | | (cherry picked from commit a96e06db77dcbd3433d39761ddb4615d7d96284a) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-38400 Don't check for NULL linked list pointers in _PyObject_IsFreed ↵Miss Islington (bot)2020-01-191-1/+4
| | | | | | | | | | | | (GH-16630) Some objects like Py_None are not initialized with conventional means that prepare the circular linked list pointers, leaving them unlinked from the rest of the objects. For those objects, NULL pointers does not mean that they are freed, so we need to skip the check in those cases. (cherry picked from commit 36e33c360ed7716a2b5ab2b53210da81f8ce1295) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* Document CodeType.replace (GH-17776)Miss Islington (bot)2019-12-312-4/+4
| | | | | (cherry picked from commit 22424c02e51fab3b62cbe255d0b87d1b55b9a6c3) Co-authored-by: Anthony Sottile <asottile@umich.edu>
* [3.8] bpo-38588: Fix possible crashes in dict and list when calling P… ↵Dong-hee Na2019-12-312-0/+12
| | | | | | | | | | | | | | | | | | | | (GH-17764) * [3.8] 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> * Update Objects/listobject.c @methane's suggestion Co-Authored-By: Inada Naoki <songofacandy@gmail.com> Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* bpo-38610: Fix possible crashes in several list methods (GH-17022)Miss Islington (bot)2019-12-301-3/+12
| | | | | | Hold strong references to list elements while calling PyObject_RichCompareBool(). (cherry picked from commit d9e561d23d994e3ed15f4fcbd7ee5c8fe50f190b) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* closes bpo-30364: Replace deprecated no_address_safety_analysis attribute. ↵Miss Islington (bot)2019-12-261-7/+7
| | | | | | | (GH-17702) (cherry picked from commit c0052f3fe3d19820b2d4f76e383035439affe32c) Co-authored-by: Batuhan Taşkaya <47358913+isidentical@users.noreply.github.com>
* bpo-38922: Raise code.__new__ audit event when code object replace() is ↵Miss Islington (bot)2019-11-261-0/+7
| | | | | | | called (GH-17394) (cherry picked from commit c7c01ab1e5415b772c68e15f1aba51e520010830) Co-authored-by: Steve Dower <steve.dower@python.org>
* bpo-35409: Ignore GeneratorExit in async_gen_athrow_throw (GH-14755)Miss Islington (bot)2019-11-191-0/+11
| | | | | | | | Ignore `GeneratorExit` exceptions when throwing an exception into the `aclose` coroutine of an asynchronous generator. https://bugs.python.org/issue35409 (cherry picked from commit 8e0de2a4808d7c2f4adedabff89ee64e0338790a) Co-authored-by: Vincent Michel <vxgmichel@gmail.com>
* bpo-38555: Fix an undefined behavior. (GH-16883)Miss Skeleton (bot)2019-10-231-8/+7
| | | | | (cherry picked from commit 2e3d873d3bd0ef4708c4fa06b6cd6972574cb9af) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-38525: Fix a segmentation fault when using reverse iterators of empty ↵Miss Islington (bot)2019-10-191-2/+7
| | | | | | | | dict (GH-16846) The reverse iterator for empty dictionaries was not handling correctly shared-key dictionaries. (cherry picked from commit 24dc2f8c56697f9ee51a4887cf0814b6600c1815) Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* [3.8] bpo-36389: Backport debug enhancements from master (GH-16796)Victor Stinner2019-10-156-158/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bpo-36389: _PyObject_CheckConsistency() available in release mode (GH-16612) bpo-36389, bpo-38376: The _PyObject_CheckConsistency() function is now also available in release mode. For example, it can be used to debug a crash in the visit_decref() function of the GC. Modify the following functions to also work in release mode: * _PyDict_CheckConsistency() * _PyObject_CheckConsistency() * _PyType_CheckConsistency() * _PyUnicode_CheckConsistency() Other changes: * _PyMem_IsPtrFreed(ptr) now also returns 1 if ptr is NULL (equals to 0). * _PyBytesWriter_CheckConsistency() now returns 1 and is only used with assert(). * Reorder _PyObject_Dump() to write safe fields first, and only attempt to render repr() at the end. (cherry picked from commit 6876257eaabdb30f27ebcbd7d2557278ce2e5705) * bpo-36389: Fix _PyBytesWriter in release mode (GH-16624) Fix _PyBytesWriter API when Python is built in release mode with assertions. (cherry picked from commit 60ec6efd96d95476fe5e38c491491add04f026e5) * bpo-38070: Enhance visit_decref() debug trace (GH-16631) subtract_refs() now pass the parent object to visit_decref() which pass it to _PyObject_ASSERT(). So if the "is freed" assertion fails, the parent is used in debug trace, rather than the freed object. The parent object is more likely to contain useful information. Freed objects cannot be inspected are are displayed as "<object at xxx is freed>" with no other detail. (cherry picked from commit 4d5f94b8cd20f804c7868c5395a15aa6032f874c) * Fix also a typo in PYMEM_DEADBYTE macro comment * bpo-36389: Add newline to _PyObject_AssertFailed() (GH-16629) Add a newline between the verbose object dump and the Py_FatalError() logs for readability. (cherry picked from commit 7775349895088a7ae68cecf0c74cf817f15e2c74)
* Fix strict-aliasing rules errors on gcc 4.8.5. (GH-16714)Miss Islington (bot)2019-10-131-1/+1
| | | | | (cherry picked from commit c39d1ddc012987e2159a997e27665d2d579c0ce0) Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* bpo-38409: Fix grammar in str.strip() docstring (GH-16682) (GH-16684)Miss Islington (bot)2019-10-092-4/+4
| | | (cherry picked from commit 09895c27cd8ff60563a794016e8c099bc897cc74)
* [3.8] bpo-38395: Fix ownership in weakref.proxy methods (GH-16632) (GH-16662)Pablo Galindo2019-10-081-31/+88
| | | | | | | | | | | | | | | | The implementation of weakref.proxy's methods call back into the Python API using a borrowed references of the weakly referenced object (acquired via PyWeakref_GET_OBJECT). This API call may delete the last reference to the object (either directly or via GC), leaving a dangling pointer, which can be subsequently dereferenced. To fix this, claim a temporary ownership of the referenced object when calling the appropriate method. Some functions because at the moment they do not need to access the borrowed referent, but to protect against future changes to these functions, ownership need to be fixed in all potentially affected methods.. (cherry picked from commit 10cd00a9e3c22af37c748ea5a417f6fb66601e21) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-38383: Fix possible integer overflow in startswith() of bytes and ↵Miss Islington (bot)2019-10-061-1/+1
| | | | | | | bytearray. (GH-16603) (cherry picked from commit 24ddd9c2d6ab61cbce7e68d6de36d4df9bd2c3fb) Co-authored-by: Hai Shi <shihai1992@gmail.com>
* Restore tp_clear for function object. (#16502)Neil Schemenauer2019-10-011-13/+21
| | | | | This is a revert of the revert (GH-15826). Having a tp_clear for functions should be safe (and helpful) now that bpo-38006 has been fixed.
* bpo-30773: Fix ag_running; prohibit running athrow/asend/aclose in parallel ↵Miss Islington (bot)2019-09-291-2/+34
| | | | | | | (GH-7468) (#16486) (cherry picked from commit fc4a044a3c54ce21e9ed150f7d769fb479d34c49) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-38115: Deal with invalid bytecode offsets in lnotab (GH-16079) (GH-16464)Gregory P. Smith2019-09-281-1/+3
| | | | | | | | | | | | Document that lnotab can contain invalid bytecode offsets (because of terrible reasons that are difficult to fix). Make dis.findlinestarts() ignore invalid offsets in lnotab. All other uses of lnotab in CPython (various reimplementations of addr2line or line2addr in Python, C and gdb) already ignore this, because they take an address to look for, instead. Add tests for the result of dis.findlinestarts() on wacky constructs in test_peepholer.py, because it's the easiest place to add them. (cherry picked from commit c8165036f374cd2ee64d4314eeb2514f7acb5026)
* bpo-38005: Remove support of string argument in InterpreterID(). (GH-16227)Miss Islington (bot)2019-09-251-50/+31
| | | | | | Make negative interpreter id to raise ValueError instead of RuntimeError. (cherry picked from commit 543a3951a1c96bae0ea839eacec71d3b1a563a10) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-38236: Dump path config at first import error (GH-16300) (GH-16332)Victor Stinner2019-09-231-8/+11
| | | | | | Python now dumps path configuration if it fails to import the Python codecs of the filesystem and stdio encodings. (cherry picked from commit fcdb027234566c4d506d6d753c7d5638490fb088)
* [3.8] bpo-38070: Py_FatalError() logs runtime state (GH-16258)Victor Stinner2019-09-181-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bpo-38070: _Py_DumpTraceback() writes <no Python frame> (GH-16244) When a Python thread has no frame, _Py_DumpTraceback() and _Py_DumpTracebackThreads() now write "<no Python frame>", rather than writing nothing. (cherry picked from commit 8fa3e1740b3f03ea65ddb68411c2238c5f98eec2) * bpo-38070: Enhance _PyObject_Dump() (GH-16243) _PyObject_Dump() now dumps the object address for freed objects and objects with ob_type=NULL. (cherry picked from commit b39afb78768418d9405c4b528c80fa968ccc974d) * bpo-38070: Add _PyRuntimeState.preinitializing (GH-16245) Add _PyRuntimeState.preinitializing field: set to 1 while Py_PreInitialize() is running. _PyRuntimeState: rename also pre_initialized field to preinitialized. (cherry picked from commit d3b904144e86e2442961de6a7dccecbe133d5c6d) * bpo-38070: Py_FatalError() logs runtime state (GH-16246) (cherry picked from commit 1ce16fb0977283ae42a9f8917bbca5f44aa69324)
* bpo-38013: make async_generator_athrow object tolerant to throwing ↵Miss Islington (bot)2019-09-171-5/+0
| | | | | | | | | | | | | exceptions (GH-16070) Even when the helper is not started yet. This behavior follows conventional generator one. There is no reason for `async_generator_athrow` to handle `gen.throw()` differently. https://bugs.python.org/issue38013 (cherry picked from commit c275312a6284bd319ea33c9abd7e15c230eca43f) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* [3.8] bpo-38005: Fixed comparing and creating of InterpreterID and ↵Serhiy Storchaka2019-09-141-51/+49
| | | | | | | | | | | | | | ChannelID. (GH-15652) (GH-16145) * Fix a crash in comparing with float (and maybe other crashes). * They are now never equal to strings and non-integer numbers. * Comparison with a large number no longer raises OverflowError. * Arbitrary exceptions no longer silenced in constructors and comparisons. * TypeError raised in the constructor contains now the name of the type. * Accept only ChannelID and int-like objects in channel functions. * Accept only InterpreterId, int-like objects and str in the InterpreterId constructor. * Accept int-like objects, not just int in interpreter related functions. (cherry picked from commit bf169915ecdd42329726104278eb723a7dda2736)
* [3.8] bpo-37206: Unrepresentable default values no longer represented as ↵Serhiy Storchaka2019-09-149-23/+23
| | | | | | | | | | None. (GH-13933) (GH-16141) In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values (like in the optional third parameter of getattr). "None" should be used if None is accepted as argument and passing None has the same effect as not passing the argument at all. (cherry picked from commit 279f44678c8b84a183f9eeb85e0b086228154497) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-38096: Complete the "structseq" and "named tuple" cleanup (GH-16010) ↵Miss Islington (bot)2019-09-121-2/+8
| | | | | | | (GH-16062) (cherry picked from commit 4210ad5ebd5769f585035e022876e161cd0e9a3e) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
* [3.8] bpo-37879: Suppress subtype_dealloc decref when base type is a C heap ↵Petr Viktorin2019-09-121-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | type (GH-15323, GH-16004) (GH-15966) The instance destructor for a type is responsible for preparing an instance for deallocation by decrementing the reference counts of its referents. If an instance belongs to a heap type, the type object of an instance has its reference count decremented while for static types, which are permanently allocated, the type object is unaffected by the instance destructor. Previously, the default instance destructor searched the class hierarchy for an inherited instance destructor and, if present, would invoke it. Then, if the instance type is a heap type, it would decrement the reference count of that heap type. However, this could result in the premature destruction of a type because the inherited instance destructor should have already decremented the reference count of the type object. This change avoids the premature destruction of the type object by suppressing the decrement of its reference count when an inherited, non-default instance destructor has been invoked. Finally, an assertion on the Py_SIZE of a type was deleted. Heap types have a non zero size, making this into an incorrect assertion. https://github.com/python/cpython/pull/15323. (cherry picked from commit ff023ed36ea260ab64be5895f1f1f087c798987a) Fixup: https://github.com/python/cpython/pull/16004. (cherry picked from commit 5e9caeec76119a0d61c25f1466c27b7dbd5115bd) Co-authored-by: Eddie Elizondo <eduardo.elizondorueda@gmail.com>
* bpo-38096: Clean up the "struct sequence" / "named tuple" docs (GH-15895) ↵Paul Ganssle2019-09-112-2/+2
| | | | (GH-15961)
* Doc: Fix typo in fastsearch comments (GH-14608) (GH-15933)Miss Islington (bot)2019-09-111-2/+2
| | | | | (cherry picked from commit 60bba83b5d9947fb3106325293e3a4e9c9cdea7e) Co-authored-by: Valentin Haenel <esc@users.noreply.github.com>
* Remove unneeded assignment in PyBytes_Concat() (GH-15274)Miss Islington (bot)2019-09-101-1/+0
| | | | | | The `wb.len = -1` assignment is unneeded since its introduction in 161d695fb0455ce52530d4f43a9eac4c738f64bb as `PyObject_GetBuffer` always fills it in. (cherry picked from commit afdeb189e97033b54cef44a7490d89d2013cb4e5) Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
* bpo-37619: update_one_slot() should not ignore wrapper descriptors for wrong ↵Miss Islington (bot)2019-09-101-6/+13
| | | | | | | type (GH-15838) (cherry picked from commit 57ea33560662e0f20a3b0334bb20065771edf4da) Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be>
* Fix typo in dict object comment (GH-15814)Miss Islington (bot)2019-09-101-1/+1
| | | | | (cherry picked from commit 359143c68659d165f52320d368667e0eff279dc5) Co-authored-by: dalgarno <32097481+dalgarno@users.noreply.github.com>
* Revert "bpo-33418: Add tp_clear for function object (GH-8058)" (GH-15826)Victor Stinner2019-09-101-21/+13
| | | This reverts commit 3c452404ae178b742967589a0bb4a5ec768d76e0.
* [3.8] bpo-37994: Fix silencing all errors if an attribute lookup fails. ↵Serhiy Storchaka2019-09-016-90/+95
| | | | | | | (GH-15630) (GH-15635) Only AttributeError should be silenced. (cherry picked from commit 41c57b335330ff48af098d47e379e0f9ba09d233)
* Fix typos mostly in comments, docs and test names (GH-15209)Miss Islington (bot)2019-08-302-2/+2
| | | | | (cherry picked from commit 39d87b54715197ca9dcb6902bb43461c0ed701a2) Co-authored-by: Min ho Kim <minho42@gmail.com>
* [3.8] bpo-37034: Display argument name on errors with keyword arguments with ↵Serhiy Storchaka2019-08-2910-56/+56
| | | | | | | Argument Clinic. (GH-13593). (GH-15599) (cherry picked from commit 4901fe274bc82b95dc89bcb3de8802a3dfedab32) Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
* Fix unused variable and signed/unsigned warnings (GH-15537) (GH-15551)Miss Islington (bot)2019-08-271-0/+6
| | | | | (cherry picked from commit 0138c4ceab1e10d42d0aa962d2ae079b46da7671) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
* [3.8] bpo-37757: Disallow PEP 572 cases that expose implementation details ↵Nick Coghlan2019-08-261-9/+0
| | | | | | | | | | | | | | | | | | | (GH-15491) - drop TargetScopeError in favour of raising SyntaxError directly as per the updated PEP 572 - comprehension iteration variables are explicitly local, but named expression targets in comprehensions are nonlocal or global. Raise SyntaxError as specified in PEP 572 - named expression targets in the outermost iterable of a comprehension have an ambiguous target scope. Avoid resolving that question now by raising SyntaxError. PEP 572 originally required this only for cases where the bound name conflicts with the iteration variable in the comprehension, but CPython can't easily restrict the exception to that case (as it doesn't know the target variable names when visiting the outermost iterator expression) (cherry picked from commit 5dbe0f59b7a4f39c7c606b48056bc29e406ebf78)
* [3.8] bpo-37830: Fix compilation of break and continue in finally. ↵Serhiy Storchaka2019-08-241-7/+16
| | | | | | | | | (GH-15320) (GH-15456) Fix compilation of "break" and "continue" in the "finally" block when the corresponding "try" block contains "return" with a non-constant value. (cherry picked from commit ef61c524ddeeb56da3858b86e349e7288d68178e)
* bpo-36311: Fixes decoding multibyte characters around chunk boundaries and ↵Miss Islington (bot)2019-08-211-6/+10
| | | | | | | improves decoding performance (GH-15083) (cherry picked from commit 7ebdda0dbee7df6f0c945a7e1e623e47676e112d) Co-authored-by: Steve Dower <steve.dower@python.org>
* bpo-37732: Fix GCC warning in _PyObject_Malloc() (GH-15333) (GH-15342)Victor Stinner2019-08-201-17/+15
| | | | | | | | | pymalloc_alloc() now returns directly the pointer, return NULL on memory allocation error. allocate_from_new_pool() already uses NULL as marker for "allocation failed". (cherry picked from commit 18f8dcfa10d8a858b152d12a9ad8fa83b7e967f0)
* bpo-37681: no_sanitize_thread support from GCC 5.1 (GH-15096)Miss Islington (bot)2019-08-141-2/+2
| | | | | | | Fix the following warning with GCC 4.8.5: Objects/obmalloc.c: warning: ‘no_sanitize_thread’ attribute directive ignored (cherry picked from commit 7e479c82218450255572e3f5fa1549dc283901ea) Co-authored-by: Hai Shi <shihai1992@gmail.com>
* [3.8] bpo-36974: separate vectorcall functions for each calling convention ↵Jeroen Demeyer2019-07-233-78/+354
| | | | (GH-13781) (#14782)
* bpo-37233: optimize method_vectorcall in case of totalargs == 0 (GH-14550)Miss Islington (bot)2019-07-031-6/+10
| | | | | (cherry picked from commit 53c214344038341ce86fcf7efa12dc33be9d5b45) Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be>