| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
(GH-11015)
Set MemoryError when appropriate, add missing failure checks,
and fix some potential leaks.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Replace strncpy() with memcpy() in structseq_repr() to fix the
following compiler warning:
Objects/structseq.c:187:5: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-overflow=]
strncpy(pbuf, typ->tp_name, len);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Objects/structseq.c:185:11: note: length computed here
len = strlen(typ->tp_name) > TYPE_MAXSIZE ? TYPE_MAXSIZE :
The function writes the terminating NUL byte later.
|
|
|
|
|
|
|
|
|
| |
Fix memory leak in PyUnicode_EncodeLocale() and
PyUnicode_EncodeFSDefault() on error handling.
Changes:
* Fix unicode_encode_locale() error handling
* Fix test_codecs.LocaleCodecTest
|
|
|
| |
Fix warnings with gcc 8 for wrapperfunc <-> wrapperfunc_kwds casts.
|
|
|
| |
Fix also return type for few other functions (clear, releasebuffer).
|
|
|
|
|
|
|
| |
'data' argument of unicode_fill() is modified, so it must not be
constant.
Add more assertions to unicode_fill(): check the maximum character
value.
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
(GH-6748)
Fix invalid function cast warnings with gcc 8
for method conventions different from METH_NOARGS, METH_O and
METH_VARARGS in Argument Clinic generated code.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix str.format(), float.__format__() and complex.__format__() methods
for non-ASCII decimal point when using the "n" formatter.
Changes:
* Rewrite _PyUnicode_InsertThousandsGrouping(): it now requires
a _PyUnicodeWriter object for the buffer and a Python str object
for digits.
* Rename FILL() macro to unicode_fill(), convert it to static inline function,
add "assert(0 <= start);" and rework its code.
|
|
|
|
| |
Move _PyTuple_ITEMS() to a new header file:
Include/internal/pycore_tupleobject.h
|
|
|
|
|
|
| |
PyObject_INIT() and PyObject_INIT_VAR() now cast their first argument
to PyObject*, as done in Python 3.7.
Revert partially commit b4435e20a92af474f117b78b98ddc6f515363af5.
|
|
|
|
|
|
|
| |
If _PyObject_Dump() detects that the object is freed, don't try to
dump it (exit immediately).
Enhance also _PyObject_IsFreed(): it now detects if the pointer
itself looks like freed memory.
|
|
|
| |
Don't pass void* to Python macros: use _PyObject_CAST().
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Don't pass complex expressions but regular variables to Python
macros.
* _datetimemodule.c: split single large "if" into two "if"
in date_new(), time_new() and datetime_new().
* _pickle.c, load_extension(): flatten complex "if" expression into
more regular C code.
* _ssl.c: addbool() now uses a temporary bool_obj to only evaluate
the value once.
* weakrefobject.c: replace "Py_INCREF(result = proxy);"
with "result = proxy; Py_INCREF(result);"
|
|
|
|
|
|
| |
Enhance _PyObject_AssertFailed()
* Exchange 'expr' and 'msg' parameters
* 'expr' and 'func' arguments can now be NULL
|
|
|
|
| |
Move _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() from
Include/objimpl.h to Include/internal/pycore_object.h.
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-10585)
coro->cr_origin wasn't initialized if compute_cr_origin() failed in
PyCoro_New(), which would cause a crash during the coroutine's
deallocation.
https://bugs.python.org/issue35269
|
|
|
|
|
|
| |
(GH-10536)
PyTuple_Pack can fail and return NULL. If this happens, then PyType_FromSpecWithBases will incorrectly create a new type without bases. Also, it will crash on the Py_DECREF that follows. Also free members and type in error conditions.
|
|
|
|
| |
Remove _Py_REF_DEBUG_COMMA, DK_DEBUG_INCREF, and DK_DEBUG_DECREF.
Convert DK_INCREF and DK_DECREF to static inline functions.
|
|
|
|
|
|
| |
Discovered using clang's MemorySanitizer when it ran python3's
test_fstring test_misformed_unicode_character_name.
An msan build will fail by simply executing: ./python -c 'u"\N"'
|
|
|
|
| |
(GH-9665)
|
|
|
|
| |
Rename our new MEMORY_SANITIZER define to _Py_MEMORY_SANITIZER.
Project based C Preprocessor namespacing at its finest. :P
|
|
|
|
| |
clang's MemorySanitizer understand getc() but does not understand
getc_unlocked(). Workaround: Don't use it on msan builds.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
address_in_range(). (GH-10442)
This function may access memory which is mapped but is considered
free by libc allocator. It behaves so by design, therefore we
need to suppress sanitizer reports.
GCC doesn't support MSan, so disable only TSan for it.
|
|
|
| |
Remove unneeded assertion (we already know so is a PySetObject *).
|
|
|
|
|
|
|
| |
* _PyTuple_ITEMS() gives access to the tuple->ob_item field and cast the
first argument to PyTupleObject*. This internal macro is only usable if
Py_BUILD_CORE is defined.
* Replace &PyTuple_GET_ITEM(ob, 0) with _PyTuple_ITEMS(ob).
* Replace PyTuple_GET_ITEM(op, 1) with &_PyTuple_ITEMS(ob)[1].
|
|
|
|
|
| |
Gives approx 20% speed-up using clang depending on the number of elements in the set (the less dense the set, the more the speed-up).
Uses the same entry++ logic used elsewhere in the setobject.c code.
|
|
|
|
| |
Move Py_BUILD_CORE code from Include/fileutils.h to a new
Include/internal/pycore_fileutils.h file.
|
| |
|
|
|
|
|
|
|
| |
The accu.h header is no longer part of the Python C API: it has been
moved to the "internal" headers which are restricted to Python
itself.
Replace #include "accu.h" with #include "pycore_accu.h".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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".
|
|
|
|
|
| |
* Add #include "internal/mem.h" to C files using
_PyMem_SetDefaultAllocator().
* Include/internal/mem.h now requires Py_BUILD_CORE to be defined.
|
| |
|
|
|
|
| |
types. (GH-6239)
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
| |
Convert _Py_Dealloc() macro into a static inline function. Moreover,
it is now also defined as a static inline function if Py_TRACE_REFS
is defined.
|
|
|
|
| |
(GH-6398)
|
|
|
|
|
|
|
|
|
|
|
|
| |
The list() constructor isn't taking full advantage of known input
lengths or length hints. This commit makes the constructor
pre-size and not over-allocate when the input size is known (the
input collection implements __len__). One on the main advantages is
that this provides 12% difference in memory savings due to the difference
between overallocating and allocating exactly the input size.
For efficiency purposes and to avoid a performance regression for small
generators and collections, the size of the input object is calculated using
__len__ and not __length_hint__, as the later is considerably slower.
|
|
|
|
|
|
|
| |
(GH-10152)
Configuring python with ./configure --with-pydebug CFLAGS="-D COUNT_ALLOCS -O0"
makes "make smelly" fail as some symbols were being exported without the "Py_" or
"_Py" prefixes.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Use _PyObject_ASSERT() in:
* _PyDict_CheckConsistency()
* _PyType_CheckConsistency()
* _PyUnicode_CheckConsistency()
_PyObject_ASSERT() dumps the faulty object if the assertion fails
to help debugging.
|
|
|
|
| |
Replace assert() with _PyObject_ASSERT() in Objects/typeobject.c
to dump the faulty object on assertion failure to ease debugging.
|
|
|
|
| |
Replace assert() with _PyObject_ASSERT() in Objects/object.c to dump
the faulty object on assertion failure to ease debugging.
|
|
|
|
|
| |
* Convert PyObject_INIT() and PyObject_INIT_VAR() macros to static
inline functions.
* Fix usage of these functions: cast to PyObject* or PyVarObject*.
|
|
|
|
| |
_Py_NegativeRefcount() now uses _PyObject_AssertFailed() to dump the
object to help debugging.
|