Serhiy Storchaka
bb36f72efc
gh-111049: Fix crash during garbage collection of the BytesIO buffer object (GH-111221)
2023-12-14 10:04:23 +00:00
Serhiy Storchaka
9da98c0d9a
gh-111174: Fix crash in getbuffer() called repeatedly for empty BytesIO (GH-111210)
2023-10-25 13:50:16 +03:00
Victor Stinner
a071ecb4d1
gh-106320: Remove private _PySys functions ( #108452 )
...
Move private functions to the internal C API (pycore_sysmodule.h):
* _PySys_GetAttr()
* _PySys_GetSizeOf()
No longer export most of these functions.
Fix also a typo in Include/cpython/optimizer.h: add a missing space.
2023-08-24 20:02:09 +00:00
Victor Stinner
1a3faba9f1
gh-106869: Use new PyMemberDef constant names ( #106871 )
...
* Remove '#include "structmember.h"'.
* If needed, add <stddef.h> to get offsetof() function.
* Update Parser/asdl_c.py to regenerate Python/Python-ast.c.
* Replace:
* T_SHORT => Py_T_SHORT
* T_INT => Py_T_INT
* T_LONG => Py_T_LONG
* T_FLOAT => Py_T_FLOAT
* T_DOUBLE => Py_T_DOUBLE
* T_STRING => Py_T_STRING
* T_OBJECT => _Py_T_OBJECT
* T_CHAR => Py_T_CHAR
* T_BYTE => Py_T_BYTE
* T_UBYTE => Py_T_UBYTE
* T_USHORT => Py_T_USHORT
* T_UINT => Py_T_UINT
* T_ULONG => Py_T_ULONG
* T_STRING_INPLACE => Py_T_STRING_INPLACE
* T_BOOL => Py_T_BOOL
* T_OBJECT_EX => Py_T_OBJECT_EX
* T_LONGLONG => Py_T_LONGLONG
* T_ULONGLONG => Py_T_ULONGLONG
* T_PYSSIZET => Py_T_PYSSIZET
* T_NONE => _Py_T_NONE
* READONLY => Py_READONLY
* PY_AUDIT_READ => Py_AUDIT_READ
* READ_RESTRICTED => Py_AUDIT_READ
* PY_WRITE_RESTRICTED => _Py_WRITE_RESTRICTED
* RESTRICTED => (READ_RESTRICTED | _Py_WRITE_RESTRICTED)
2023-07-25 15:28:30 +02:00
Erlend E. Aasland
186bf39f5c
gh-101819: Isolate `_io` ( #101948 )
...
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-05-15 09:26:27 +00:00
Erlend E. Aasland
7a7eaff95c
gh-101819: Port _io.PyBytesIOBuffer_Type to heap type ( #104264 )
2023-05-07 14:01:27 +00:00
Victor Stinner
c84029179c
gh-101819: Prepare to modernize the _io extension ( #104178 )
...
* Add references to static types to _PyIO_State:
* PyBufferedIOBase_Type
* PyBytesIOBuffer_Type
* PyIncrementalNewlineDecoder_Type
* PyRawIOBase_Type
* PyTextIOBase_Type
* Add the defining class to methods:
* _io.BytesIO.getbuffer()
* _io.FileIO.close()
* Add get_io_state_by_cls() function.
* Add state parameter to _textiowrapper_decode()
* _io_TextIOWrapper___init__() now sets self->state before calling
_textiowrapper_set_decoder().
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-05-06 01:53:55 +02:00
Erlend E. Aasland
c00faf7943
gh-101819: Adapt _io types to heap types, batch 1 (GH-101949)
...
Adapt StringIO, TextIOWrapper, FileIO, Buffered*, and BytesIO types.
Automerge-Triggered-By: GH:erlend-aasland
2023-02-20 05:46:20 -08:00
Victor Stinner
85dd6cb6df
gh-99845: Use size_t type in __sizeof__() methods ( #99846 )
...
The implementation of __sizeof__() methods using _PyObject_SIZE() now
use an unsigned type (size_t) to compute the size, rather than a signed
type (Py_ssize_t).
Cast explicitly signed (Py_ssize_t) values to unsigned type
(Py_ssize_t).
2022-11-30 17:22:52 +01:00
Victor Stinner
7e4dec02ac
gh-99300: Use Py_NewRef() in Modules/ directory ( #99467 )
...
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in test C files of the Modules/ directory.
2022-11-14 13:08:43 +01:00
Victor Stinner
7974c30b9f
bpo-45094: Add Py_NO_INLINE macro (GH-28140)
...
* Rename _Py_NO_INLINE macro to Py_NO_INLINE: make it public and
document it.
* Sort macros in the C API documentation.
2021-09-03 16:44:02 +02:00
Victor Stinner
4a21e57fe5
bpo-40268: Remove unused structmember.h includes (GH-19530)
...
If only offsetof() is needed: include stddef.h instead.
When structmember.h is used, add a comment explaining that
PyMemberDef is used.
2020-04-15 02:35:41 +02:00
Serhiy Storchaka
8f87eefe7f
bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. (GH-19472)
2020-04-12 14:58:27 +03:00
Vinay Sajip
0b60f64e43
bpo-11410: Standardize and use symbol visibility attributes across POSIX and Windows. (GH-16347)
2019-10-15 08:26:12 +01:00
Min ho Kim
39d87b5471
Fix typos mostly in comments, docs and test names (GH-15209)
2019-08-30 16:21:19 -04:00
Sergey Fedoseev
3e41f3cabb
bpo-34488: optimize BytesIO.writelines() (GH-8904)
...
Avoid the creation of unused int object for each line.
2019-08-07 09:38:31 +09:00
Zackery Spytz
36dcaab7fd
Fix the error handling in bytesio_sizeof(). (GH-10459)
...
bytesio_sizeof() must check if an error has occurred in _PySys_GetSizeOf().
2019-06-02 00:07:45 +03:00
Jeroen Demeyer
530f506ac9
bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async (GH-13464)
...
Automatically replace
tp_print -> tp_vectorcall_offset
tp_compare -> tp_as_async
tp_reserved -> tp_as_async
2019-05-30 19:13:39 -07:00
Serhiy Storchaka
d4f9cf5545
bpo-33029: Fix signatures of getter and setter functions. (GH-10746)
...
Fix also return type for few other functions (clear, releasebuffer).
2018-11-27 19:34:35 +02:00
Victor Stinner
bcda8f1d42
bpo-35081: Add Include/internal/pycore_object.h (GH-10640)
...
Move _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() from
Include/objimpl.h to Include/internal/pycore_object.h.
2018-11-21 22:27:47 +01:00
Siddhesh Poyarekar
55edd0c185
bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. (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.
2018-04-29 21:59:33 +03:00
INADA Naoki
a6296d34a4
bpo-31095: fix potential crash during GC (GH-2974)
2017-08-24 14:55:17 +09:00
Serhiy Storchaka
762bf40438
bpo-29852: Argument Clinic Py_ssize_t converter now supports None ( #716 )
...
if pass `accept={int, NoneType}`.
2017-03-30 09:15:31 +03:00
Serhiy Storchaka
fff9a31a91
bpo-29865: Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types. ( #748 )
2017-03-21 08:53:25 +02:00
Oren Milman
004251059b
bpo-29730: replace some calls to PyNumber_Check and improve some error messages ( #650 )
2017-03-13 00:37:05 +02:00
orenmn
740025478d
bpo-29741: Clean up C implementations of BytesIO and StringIO. ( #606 )
...
Some BytesIO methods now accept not just int subclasses but other int-like types.
2017-03-11 00:52:01 +02:00
Martin Panter
ccb2c0e310
Issue #23214 : Implement optional BufferedReader, BytesIO read1() argument
2016-10-20 23:48:14 +00:00
Martin Panter
c249221dfd
Issue #20699 : Merge io bytes-like fixes from 3.5
2016-05-28 01:07:08 +00:00
Martin Panter
6bb91f3b6e
Issue #20699 : Document that “io” methods accept bytes-like objects
...
This matches the usage of ZipFile and BufferedWriter. This still requires
return values to be bytes() objects.
Also document and test that the write() methods should only access their
argument before they return.
2016-05-28 00:41:57 +00:00
Martin Panter
8b04a945ef
Merge typo fixes from 3.5
2016-04-16 09:29:17 +00:00
Martin Panter
119e502277
Fix typos in code comments and documentation
2016-04-16 09:28:57 +00:00
Serhiy Storchaka
f01e408c16
Issue #26200 : Added Py_SETREF and replaced Py_XSETREF with Py_SETREF
...
in places where Py_DECREF was used.
2016-04-10 18:12:01 +03:00
Serhiy Storchaka
ec39756960
Issue #22570 : Renamed Py_SETREF to Py_XSETREF.
2016-04-06 09:50:03 +03:00
Serhiy Storchaka
48842714b9
Issue #22570 : Renamed Py_SETREF to Py_XSETREF.
2016-04-06 09:45:48 +03:00
Serhiy Storchaka
1ed017ae92
Issue #20440 : Cleaning up the code by using Py_SETREF and Py_CLEAR.
...
Old code is correct, but with Py_SETREF and Py_CLEAR it can be cleaner.
This patch doesn't fix bugs and hence there is no need to backport it.
2015-12-27 15:51:32 +02:00
Serhiy Storchaka
5a57ade58e
Issue #20440 : Massive replacing unsafe attribute setting code with special
...
macro Py_SETREF.
2015-12-24 10:35:59 +02:00
Serhiy Storchaka
5c4064e8bd
Issue #25421 : __sizeof__ methods of builtin types now use dynamic basic size.
...
This allows sys.getsize() to work correctly with their subclasses with
__slots__ defined.
2015-12-19 20:05:25 +02:00
Serhiy Storchaka
4e63f7a2b4
Issue #24989 : Fixed buffer overread in BytesIO.readline() if a position is
...
set beyond size. Based on patch by John Leitch.
2015-09-04 07:48:19 +03:00
Larry Hastings
dbfdc380df
Issue #24001 : Argument Clinic converters now use accept={type}
...
instead of types={'type'} to specify the types the converter accepts.
2015-05-04 06:59:46 -07:00
Serhiy Storchaka
f24131ff31
Issue #20175 : Converted the _io module to Argument Clinic.
2015-04-16 11:19:43 +03:00
Serhiy Storchaka
5056769b36
Replaced "string" with "bytes object" in docstrings of binary I/O objects.
2015-04-10 02:19:57 +03:00
Serhiy Storchaka
b817b77a8c
Replaced "string" with "bytes object" in docstrings of binary I/O objects.
2015-04-10 02:18:44 +03:00
Stefan Krah
650c1e818d
Issue #14203 : Remove obsolete support for view==NULL in bytesiobuf_getbuffer()
...
and array_buffer_getbuf().
2015-02-03 21:43:23 +01:00
Serhiy Storchaka
38c30e6c8e
Issue #15381 : Fixed a bug in BytesIO.write().
...
It was expected that string_size == PyBytes_GET_SIZE(buf) if the buffer is
shared, but truncate() and __setstate__() can set string_size without
unsharing the buffer.
2015-02-03 18:51:58 +02:00
Serhiy Storchaka
b9765eec5c
Issue #15381 : Try to fix refcount bug. Empty and 1-byte buffers are always shared.
2015-02-03 14:57:49 +02:00
Serhiy Storchaka
87d0b45485
Issue #15381 : Optimized io.BytesIO to make less allocations and copyings.
2015-02-03 11:30:10 +02:00
Serhiy Storchaka
32ca3dcb97
Issue #23099 : Closing io.BytesIO with exported buffer is rejected now to
...
prevent corrupting exported buffer.
2015-02-03 09:30:51 +02:00
Serhiy Storchaka
c057c3859c
Issue #23099 : Closing io.BytesIO with exported buffer is rejected now to
...
prevent corrupting exported buffer.
2015-02-03 02:00:18 +02:00
Serhiy Storchaka
3dd3e26680
Issue #22896 : Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()
...
and PyObject_AsWriteBuffer().
2015-02-03 01:25:42 +02:00
Serhiy Storchaka
4fdb68491e
Issue #22896 : Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()
...
and PyObject_AsWriteBuffer().
2015-02-03 01:21:08 +02:00