summaryrefslogtreecommitdiff
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* bpo-39087: Optimize PyUnicode_AsUTF8AndSize() (GH-18327)Inada Naoki2020-02-272-43/+90
| | | Avoid using temporary bytes object.
* bpo-39737: Remove code repitition in list_richcompare (GH-18638)sweeneyde2020-02-261-2/+1
| | | I may speed up list comparison on some platforms.
* bpo-36144: Dictionary Union (PEP 584) (#12088)Brandt Bucher2020-02-241-18/+53
|
* Give proper credits for the memoryview implementation. (#18626)Stefan Krah2020-02-241-1/+11
|
* bpo-39382: Avoid dangling object use in abstract_issubclass() (GH-18530)Yonatan Goldschmidt2020-02-221-3/+9
| | | | | Hold reference of __bases__ tuple until tuple item is done with, because by dropping the reference the item may be destroyed.
* closes bpo-39684: Combine two if/thens and squash uninit var warning. (GH-18565)Andy Lester2020-02-201-8/+3
|
* bpo-37207: Use vectorcall for range() (GH-18464)Petr Viktorin2020-02-181-17/+33
| | | | | | | This continues the `range()` part of #13930. The complete pull request is stalled on discussions around dicts, but `range()` should not be controversial. (And I plan to open PRs for other parts if this is merged.) On top of Mark's change, I unified `range_new` and `range_vectorcall`, which had a lot of duplicate code. https://bugs.python.org/issue37207
* bpo-36347: stop using RESTRICTED constants (GH-12684)Jeroen Demeyer2020-02-183-10/+8
| | | | | | | | The constants `RESTRICTED` and `PY_WRITE_RESTRICTED` no longer have a meaning in Python 3. Therefore, CPython should not use them. CC @matrixise https://bugs.python.org/issue36347
* bpo-39500: Fix compile warnings in unicodeobject.c (GH-18519)Hai Shi2020-02-171-2/+2
|
* bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)Dong-hee Na2020-02-173-8/+8
|
* bpo-39573: Update clinic to use Py_IS_TYPE() function (GH-18507)Dong-hee Na2020-02-141-2/+2
|
* closes bpo-39630: Update pointers to string literals to be const char *. ↵Andy Lester2020-02-132-3/+3
| | | | (GH-18510)
* bpo-39573: Add Py_IS_TYPE() function (GH-18488)Dong-hee Na2020-02-131-1/+1
| | | Co-Author: Neil Schemenauer <nas-github@arctrix.com>
* bpo-39606: allow closing async generators that are already closed (GH-18475)Nathaniel J. Smith2020-02-131-4/+11
| | | | | | | | | | | | | | 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
* bpo-35081: Move dtoa.h header to the internal C API (GH-18489)Victor Stinner2020-02-121-0/+1
| | | | | | | Move the dtoa.h header file to the internal C API as pycore_dtoa.h: it only contains private functions (prefixed by "_Py"). The math and cmath modules must now be compiled with the Py_BUILD_CORE macro defined.
* bpo-35081: Move bytes_methods.h to the internal C API (GH-18492)Victor Stinner2020-02-125-5/+5
| | | | | Move the bytes_methods.h header file to the internal C API as pycore_bytes_methods.h: it only contains private symbols (prefixed by "_Py"), except of the PyDoc_STRVAR_shared() macro.
* bpo-39605: Remove a cast that causes a warning. (GH-18473)Benjamin Peterson2020-02-111-1/+1
|
* closes bpo-39605: Fix some casts to not cast away const. (GH-18453)Andy Lester2020-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
* bpo-39245: Switch to public API for Vectorcall (GH-18460)Petr Viktorin2020-02-1119-48/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* bpo-39500: Document PyUnicode_IsIdentifier() function (GH-18397)Victor Stinner2020-02-111-14/+33
| | | | PyUnicode_IsIdentifier() does not call Py_FatalError() anymore if the string is not ready.
* bpo-39573: Use Py_SET_SIZE() function (GH-18402)Victor Stinner2020-02-077-54/+61
| | | | Replace direct acccess to PyVarObject.ob_size with usage of the Py_SET_SIZE() function.
* bpo-39573: Add Py_SET_SIZE() function (GH-18400)Victor Stinner2020-02-071-1/+1
| | | Add Py_SET_SIZE() function to set the size of an object.
* bpo-39573: Use Py_TYPE() macro in object.c (GH-18398)Victor Stinner2020-02-071-12/+8
| | | | Replace direct acccess to PyVarObject.ob_size with usage of the Py_SIZE() macro.
* bpo-39573: Add Py_SET_TYPE() function (GH-18394)Victor Stinner2020-02-075-11/+15
| | | Add Py_SET_TYPE() function to set the type of an object.
* bpo-39573: Use Py_TYPE() macro in Objects directory (GH-18392)Victor Stinner2020-02-0720-109/+109
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* bpo-39573: Use Py_TYPE() in abstract.c (GH-18390)Victor Stinner2020-02-071-94/+94
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* bpo-39573: Add Py_SET_REFCNT() function (GH-18389)Victor Stinner2020-02-073-7/+8
| | | | Add a Py_SET_REFCNT() function to set the reference counter of an object.
* bpo-39573: Use Py_REFCNT() macro (GH-18388)Victor Stinner2020-02-076-28/+30
| | | | Replace direct acccess to PyObject.ob_refcnt with usage of the Py_REFCNT() macro.
* bpo-39542: Declare _Py_AddToAllObjects() in pycore_object.h (GH-18368)Victor Stinner2020-02-051-1/+1
| | | | | | _Py_AddToAllObjects() is used in bltinmodule.c and typeobject.c when Py_TRACE_REFS is defined. Fix Py_TRACE_REFS build.
* Add PyInterpreterState.fs_codec.utf8 (GH-18367)Victor Stinner2020-02-051-46/+47
| | | | | | Add a fast-path for UTF-8 encoding in PyUnicode_EncodeFSDefault() and PyUnicode_DecodeFSDefaultAndSize(). Add _PyUnicode_FiniEncodings() helper function for _PyUnicode_Fini().
* bpo-39542: Make PyObject_INIT() opaque in limited C API (GH-18363)Victor Stinner2020-02-051-4/+8
| | | | | | | | | | | | | | In the limited C API, PyObject_INIT() and PyObject_INIT_VAR() are now defined as aliases to PyObject_Init() and PyObject_InitVar() to make their implementation opaque. It avoids to leak implementation details in the limited C API. Exclude the following functions from the limited C API, move them from object.h to cpython/object.h: * _Py_NewReference() * _Py_ForgetReference() * _PyTraceMalloc_NewReference() * _Py_GetRefTotal()
* bpo-39543: Remove unused _Py_Dealloc() macro (GH-18361)Victor Stinner2020-02-051-2/+0
| | | | | | | | | | | | The macro is defined after Py_DECREF() and so is no longer used by Py_DECREF(). Moving _Py_Dealloc() macro back from cpython/object.h to object.h would require to move a lot of definitions as well: PyTypeObject and many related types used by PyTypeObject. Keep _Py_Dealloc() as an opaque function call to avoid leaking implementation details in the limited C API (object.h): remove _Py_Dealloc() macro from cpython/object.h.
* bpo-39542: Make _Py_NewReference() opaque in C API (GH-18346)Victor Stinner2020-02-051-1/+17
| | | | | | | | | | _Py_NewReference() becomes a regular opaque function, rather than a static inline function in the C API (object.h), to better hide implementation details. Move _Py_tracemalloc_config from public pymem.h to internal pycore_pymem.h header. Make _Py_AddToAllObjects() private.
* Restore PyObject_IsInstance() comment (GH-18345)Victor Stinner2020-02-041-17/+23
| | | | | | | | | | | | Restore PyObject_IsInstance() comment explaining why only tuples of types are accepted, but not general sequence. Comment written by Guido van Rossum in commit 03290ecbf1661c0192e6abdbe00ae163af461d77 which implements isinstance(x, (A, B, ...)). The comment was lost in a PyObject_IsInstance() optimization: commit ec569b794737be248671d0dfac11b664fc930eef. Cleanup also the code. recursive_isinstance() is no longer recursive, so rename it to object_isinstance(), whereas object_isinstance() is recursive and so rename it to object_recursive_isinstance().
* bpo-39542: Simplify _Py_NewReference() (GH-18332)Victor Stinner2020-02-035-28/+40
| | | | | | | | | * Remove _Py_INC_REFTOTAL and _Py_DEC_REFTOTAL macros: modify directly _Py_RefTotal. * _Py_ForgetReference() is no longer defined if the Py_TRACE_REFS macro is not defined. * Remove _Py_NewReference() implementation from object.c: unify the two implementations in object.h inline function. * Fix Py_TRACE_REFS build: _Py_INC_TPALLOCS() macro has been removed.
* Fixes in sorting descriptions (GH-18317)Stefan Pochmann2020-02-031-8/+8
| | | | | Improvements in listsort.txt and a comment in sortperf.py. Automerge-Triggered-By: @csabella
* bpo-39489: Remove COUNT_ALLOCS special build (GH-18259)Victor Stinner2020-02-035-234/+0
| | | | | | | | | | | Remove: * COUNT_ALLOCS macro * sys.getcounts() function * SHOW_ALLOC_COUNT code in listobject.c * SHOW_TRACK_COUNT code in tupleobject.c * PyConfig.show_alloc_count field * -X showalloccount command line option * @test.support.requires_type_collecting decorator
* bpo-36051: Fix compiler warning. (GH-18325)Inada Naoki2020-02-031-1/+1
|
* Fix 5-space indentation and trailing whitespace (GH-18311)Mark Dickinson2020-02-021-11/+11
|
* bpo-39487: Merge duplicated _Py_IDENTIFIER identifiers in C code (GH-18254)Hai Shi2020-01-308-22/+17
| | | Moving repetitive `_Py_IDENTIFIER` instances to a global location helps identify them more easily in regards to sub-interpreter support.
* bpo-39434: Improve float __floordiv__ performance and error message (GH-18147)Dong-hee Na2020-01-301-31/+39
|
* bpo-38631: Add _Py_NO_RETURN to functions calling Py_FatalError() (GH-18278)Victor Stinner2020-01-302-4/+4
| | | | | | | | | Add _Py_NO_RETURN to functions calling Py_FatalError(): * _PyObject_AssertFailed() * dummy_dealloc() * faulthandler_fatal_error_thread() * none_dealloc() * notimplemented_dealloc()
* bpo-38631: Avoid Py_FatalError() in unicodeobject.c (GH-18281)Victor Stinner2020-01-301-23/+28
| | | | | Replace Py_FatalError() calls with _PyErr_WriteUnraisableMsg(), _PyObject_ASSERT_FAILED_MSG() or Py_UNREACHABLE() in unicode_dealloc() and unicode_release_interned().
* bpo-38631: Replace tp_new_wrapper() fatal error with SystemError (GH-18262)Victor Stinner2020-01-301-2/+6
| | | | tp_new_wrapper() now raises a SystemError if called with non-type self, rather than calling Py_FatalError() which cannot be catched.
* bpo-38631: Avoid Py_FatalError() in init_slotdefs() (GH-18263)Victor Stinner2020-01-302-16/+25
| | | | | | Rename init_slotdefs() to _PyTypes_InitSlotDefs() and add a return value of type PyStatus. The function is now called exactly once from _PyTypes_Init(). Replace calls to init_slotdefs() with an assertion checking that slotdefs is initialized.
* bpo-38631: Replace Py_FatalError() with _PyObject_ASSERT_FAILED_MSG() (GH-18258)Victor Stinner2020-01-302-32/+32
| | | | | | | | | | | | | | Replace Py_FatalError() with _PyObject_ASSERT_FAILED_MSG() in object.c and typeobject.c to also dump the involved Python object on a fatal error. It should ease debug when such fatal error occurs. If the double linked list is inconsistent, _Py_ForgetReference() no longer dumps previous and next objects in the fatal error, it now only dumps the current object. It ensures that the error message is displayed even if dumping the object does crash Python. Enhance _Py_ForgetReference() error messages; _PyObject_ASSERT_FAILED_MSG() logs the "_Py_ForgetReference" function name.
* Remove deadcode in _Py_inc_count() (GH-18257)Victor Stinner2020-01-291-2/+0
| | | | (tp->tp_next != NULL) check became redundant with commit 45294a9562e5c360ee8ef8498d8792e05a6eb25e (merged in 2006).
* bpo-36051: Drop GIL during large bytes.join() (GH-17757)Bruce Merry2020-01-291-17/+40
| | | | | Improve multi-threaded performance by dropping the GIL in the fast path of bytes.join. To avoid increasing overhead for small joins, it is only done if the output size exceeds a threshold.
* bpo-38631: Avoid Py_FatalError() in PyCode_New() (GH-18215)Victor Stinner2020-01-271-26/+46
| | | | | | | intern_strings() now raises a SystemError, rather than calling Py_FatalError(). intern_string_constants() now reports exceptions to the caller, rather than ignoring silently exceptions.
* bpo-38631: Avoid Py_FatalError() in _memory_release() (GH-18214)Victor Stinner2020-01-271-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.