| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
When very large data remains in TextIOWrapper, flush() may fail forever.
So prevent that data larger than chunk_size is remained in TextIOWrapper internal
buffer.
Co-Authored-By: Eryk Sun.
(cherry picked from commit 01806d5beba3d208bb56adba6829097d803bf54f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When called on a closed object, readinto() segfaults on account
of a write to a freed buffer:
==220553== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==220553== Access not within mapped region at address 0x2A
==220553== at 0x48408A0: memmove (vg_replace_strmem.c:1272)
==220553== by 0x58DB0C: _buffered_readinto_generic (bufferedio.c:972)
==220553== by 0x58DCBA: _io__Buffered_readinto_impl (bufferedio.c:1053)
==220553== by 0x58DCBA: _io__Buffered_readinto (bufferedio.c.h:253)
Reproducer:
reader = open ("/dev/zero", "rb")
_void = reader.read (42)
reader.close ()
reader.readinto (bytearray (42)) GH-GH-GH- BANG!
The problem exists since 2012 when commit dc469454ec added code
to free the read buffer on close().
Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com>
(cherry picked from commit cb1c0746f277052e45a60d6c436a765e34722821)
Co-authored-by: Philipp Gesang <phg@phi-gamma.net>
|
|
|
|
|
|
| |
files. (GH-17136)
This change, which follows the behavior of C stdio's fdopen and Python 2's file object, allows pipes to be opened in append mode..
(cherry picked from commit 74fa9f723f700a342e582b5ad4b51a2c4801cd1c)
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
| |
(cherry picked from commit 39d87b54715197ca9dcb6902bb43461c0ed701a2)
Co-authored-by: Min ho Kim <minho42@gmail.com>
|
|
|
|
|
|
|
| |
Argument Clinic. (GH-13593). (GH-15599)
(cherry picked from commit 4901fe274bc82b95dc89bcb3de8802a3dfedab32)
Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
|
|
|
|
|
|
|
| |
streams. (GH-15543)
(cherry picked from commit b235a1b47394eedc5f8ea4cf214f56c4c6932e59)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
| |
bytesio_sizeof() must check if an error has occurred in _PySys_GetSizeOf().
|
|
|
|
|
|
|
|
|
| |
(GH-13464)
Automatically replace
tp_print -> tp_vectorcall_offset
tp_compare -> tp_as_async
tp_reserved -> tp_as_async
|
|
|
|
|
|
|
|
| |
(GH-4944)
It is now allowed to add new fields at the end of the PyTypeObject struct without having to allocate a dedicated compatibility flag in tp_flags.
This will reduce the risk of running out of bits in the 32-bit tp_flags value.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add a whole new documentation page:
"Python Initialization Configuration"
* PyWideStringList_Append() return type is now PyStatus,
instead of int
* PyInterpreterState_New() now calls PyConfig_Clear() if
PyConfig_InitPythonConfig() fails.
* Rename files:
* Python/coreconfig.c => Python/initconfig.c
* Include/cpython/coreconfig.h => Include/cpython/initconfig.h
* Include/internal/: pycore_coreconfig.h => pycore_initconfig.h
* Rename structures
* _PyCoreConfig => PyConfig
* _PyPreConfig => PyPreConfig
* _PyInitError => PyStatus
* _PyWstrList => PyWideStringList
* Rename PyConfig fields:
* use_module_search_paths => module_search_paths_set
* module_search_path_env => pythonpath_env
* Rename PyStatus field: _func => func
* PyInterpreterState: rename core_config field to config
* Rename macros and functions:
* _PyCoreConfig_SetArgv() => PyConfig_SetBytesArgv()
* _PyCoreConfig_SetWideArgv() => PyConfig_SetArgv()
* _PyCoreConfig_DecodeLocale() => PyConfig_SetBytesString()
* _PyInitError_Failed() => PyStatus_Exception()
* _Py_INIT_ERROR_TYPE_xxx enums => _PyStatus_TYPE_xxx
* _Py_UnixMain() => Py_BytesMain()
* _Py_ExitInitError() => Py_ExitStatusException()
* _Py_PreInitializeFromArgs() => Py_PreInitializeFromBytesArgs()
* _Py_PreInitializeFromWideArgs() => Py_PreInitializeFromArgs()
* _Py_PreInitialize() => Py_PreInitialize()
* _Py_RunMain() => Py_RunMain()
* _Py_InitializeFromConfig() => Py_InitializeFromConfig()
* _Py_INIT_XXX() => _PyStatus_XXX()
* _Py_INIT_FAILED() => _PyStatus_EXCEPTION()
* Rename 'err' PyStatus variables to 'status'
* Convert RUN_CODE() macro to config_run_code() static inline function
* Remove functions:
* _Py_InitializeFromArgs()
* _Py_InitializeFromWideArgs()
* _PyInterpreterState_GetCoreConfig()
|
|
|
| |
Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
|
| |
|
|
|
|
|
|
| |
Replace global configuration variables with core_config read from the
current interpreter.
Cleanup dynload_hpux.c.
|
| |
|
| |
|
|
|
|
|
| |
In development mode (-X dev) and in debug build, the io.IOBase
destructor now logs close() exceptions. These exceptions are silent
by default in release mode.
|
|
|
|
| |
(GH-12058)
|
| |
|
|
|
| |
Bug introduced by 848037c.
|
|
|
|
|
|
|
| |
The previous code hardcoded `SEEK_SET`, etc. While it's very unlikely
that these values will change, it's best to use the definitions to avoid
there being mismatches in behavior with the code in the future.
Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
|
|
|
|
|
| |
Use _PyArg_CheckPositional() and inlined code instead of
PyArg_UnpackTuple() and _PyArg_UnpackStack() if all parameters
are positional and use the "object" converter.
|
|
|
|
| |
(GH-11313)
|
|
|
|
| |
parameter. (GH-9689)
|
|
|
|
| |
(GH-11175)
|
|
|
|
|
|
| |
(GH-11015)
Set MemoryError when appropriate, add missing failure checks,
and fix some potential leaks.
|
|
|
| |
Fix also return type for few other functions (clear, releasebuffer).
|
|
|
|
|
|
|
|
| |
(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.
|
|
|
|
| |
Move _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() from
Include/objimpl.h to Include/internal/pycore_object.h.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
| |
(GH-10284)
Two kind of mistakes:
1. Missed space. After concatenating there is no space between words.
2. Missed comma. Causes unintentional concatenating in a list of strings.
|
|
|
|
|
|
|
| |
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".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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".
|
|
|
|
|
|
| |
(GH-10217)
_io.IncrementalNewlineDecoder's initializer possibly assigns out-of-range
value to the bitwise struct field.
|
|
|
|
| |
types. (GH-6239)
|
|
|
|
|
|
|
|
|
| |
If buffering=1 is specified for open() in binary mode, it is silently
treated as buffering=-1 (i.e., the default buffer size).
Coupled with the fact that line buffering is always supported in Python 2,
such behavior caused several issues (e.g., bpo-10344, bpo-21332).
Warn that line buffering is not supported if open() is called with
binary mode and buffering=1.
|
| |
|
|
|
| |
On macOS, fix reading from and writing into a file with a size larger than 2 GiB.
|
| |
|
| |
|
| |
|
|
|
|
| |
(GH-7911)
|
|
|
|
| |
exception set (GH-8282)
|
|
|
|
|
|
|
|
|
|
|
| |
They can be exposed when some C API calls fail due to lack of
memory.
* Failed Py_BuildValue() could cause an assertion error in the
following TextIOWrapper.tell().
* input_chunk could be decrefed twice in TextIOWrapper.seek()
after failed Py_BuildValue().
* initvalue could leak in StringIO.__getstate__() after failed
PyDict_Copy().
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
(GH-6030)
METH_NOARGS functions need only a single argument but they are cast
into a PyCFunction, which takes two arguments. This triggers an
invalid function cast warning in gcc8 due to the argument mismatch.
Fix this by adding a dummy unused argument.
|
| |
|
|
|
| |
Ensure that ``truncate()`` preserves the file position (as reported by ``tell()``) after writes longer than the buffer size.
|