stratakis
e8b1965639
bpo-23699: Use a macro to reduce boilerplate code in rich comparison functions (GH-793)
2017-11-02 20:32:54 +10:00
Serhiy Storchaka
a2314283ff
bpo-20047: Make bytearray methods partition() and rpartition() rejecting ( #4158 )
...
separators that are not bytes-like objects.
2017-10-29 02:11:54 +03:00
Serhiy Storchaka
b3a77964ea
bpo-27541: Reprs of subclasses of some classes now contain actual type name. ( #3631 )
...
Affected classes are bytearray, array, deque, defaultdict, count and repeat.
2017-09-21 14:24:13 +03:00
Eric Snow
2ebc5ce42a
bpo-30860: Consolidate stateful runtime globals. ( #3397 )
...
* group the (stateful) runtime globals into various topical structs
* consolidate the topical structs under a single top-level _PyRuntimeState struct
* add a check-c-globals.py script that helps identify runtime globals
Other globals are excluded (see globals.txt and check-c-globals.py).
2017-09-07 23:51:28 -06:00
Stefan Krah
dce6502059
bpo-31279: Silence -Wstringop-overflow warning. ( #3207 )
2017-08-25 20:12:05 +02:00
Serhiy Storchaka
b879fe82e7
Expand the PySlice_GetIndicesEx macro. ( #1023 )
2017-04-08 09:53:51 +03:00
Serhiy Storchaka
6b5a9ec478
bpo-29116: Fix error messages for concatenating bytes and bytearray with unsupported type. ( #709 )
2017-03-19 19:47:02 +02:00
Serhiy Storchaka
202fda55c2
bpo-24037: Add Argument Clinic converter `bool(accept={int})`. ( #485 )
2017-03-12 10:10:47 +02:00
INADA Naoki
7ed28a8914
Merge 3.6
2017-01-06 17:44:43 +09:00
INADA Naoki
a634e23209
Issue #29159 : Fix regression in bytes(x) when x.__index__() raises Exception.
2017-01-06 17:32:01 +09:00
Victor Stinner
de4ae3d486
Backed out changeset b9c9691c72c5
...
Issue #28858 : The change b9c9691c72c5 introduced a regression. It seems like
_PyObject_CallArg1() uses more stack memory than
PyObject_CallFunctionObjArgs().
2016-12-04 22:59:09 +01:00
Victor Stinner
27580c1fb5
Replace PyObject_CallFunctionObjArgs() with fastcall
...
* PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func)
* PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg)
PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires
extra work to "parse" C arguments to build a C array of PyObject*.
_PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate
memory on the C stack.
This change is part of the fastcall project. The change on listsort() is
related to the issue #23507 .
2016-12-01 14:43:22 +01:00
Serhiy Storchaka
460bd0d284
Issue #19569 : Compiler warnings are now emitted if use most of deprecated
...
functions.
2016-11-20 12:16:46 +02:00
Raymond Hettinger
15f44ab043
Issue #27895 : Spelling fixes (Contributed by Ville Skyttä).
2016-08-30 10:47:49 -07:00
Martin Panter
1b6c6da85d
Issue #27506 : Support bytes/bytearray.translate() delete as keyword argument
...
Patch by Xiang Zhang.
2016-08-27 08:35:02 +00:00
Serhiy Storchaka
eb24988962
Issue #27704 : Optimized creating bytes and bytearray from byte-like objects
...
and iterables. Speed up to 3 times for short objects. Original patch by
Naoki Inada.
2016-08-15 09:46:07 +03:00
Martin Panter
bd09f15b69
Issue #27507 : Merge overflow check from 3.5
2016-07-18 08:18:32 +00:00
Martin Panter
371731ebfd
Issue #27507 : Check for integer overflow in bytearray.extend()
...
Patch by Xiang Zhang.
2016-07-18 07:53:13 +00:00
Serhiy Storchaka
ca0da9b0a3
Issue #27473 : Fixed possible integer overflow in bytes and bytearray
...
concatenations. Patch by Xiang Zhang.
2016-07-10 20:51:35 +03:00
Serhiy Storchaka
06cfb0cd70
Issue #27473 : Fixed possible integer overflow in bytes and bytearray
...
concatenations. Patch by Xiang Zhang.
2016-07-10 20:48:43 +03:00
Serhiy Storchaka
6c94d10a19
Issue #27443 : __length_hint__() of bytearray itearator no longer return
...
negative integer for resized bytearray.
2016-07-03 14:42:17 +03:00
Serhiy Storchaka
af65872da2
Issue #27443 : __length_hint__() of bytearray itearator no longer return
...
negative integer for resized bytearray.
2016-07-03 14:41:36 +03:00
Serhiy Storchaka
e09132f2c7
Backed out changeset b0087e17cd5e (issue #26765 )
...
For unknown reasons it perhaps caused a crash on 32-bit Windows (issue #).
2016-07-03 13:57:48 +03:00
Serhiy Storchaka
355048970b
Issue #26765 : Moved wrappers for bytes and bytearray methods to common header
...
file.
2016-07-01 17:57:30 +03:00
Serhiy Storchaka
0855e706aa
Issue #27007 : The fromhex() class methods of bytes and bytearray subclasses
...
now return an instance of corresponding subclass.
2016-07-01 17:22:31 +03:00
Serhiy Storchaka
4b23494ded
Issue #27039 : Fixed bytearray.remove() for values greater than 127.
...
Based on patch by Joe Jevnik.
2016-05-16 22:24:03 +03:00
Serhiy Storchaka
7bf36dace8
Issue #27039 : Fixed bytearray.remove() for values greater than 127.
...
Patch by Joe Jevnik.
2016-05-16 22:15:38 +03:00
Serhiy Storchaka
fb81d3cbe7
Issue #26765 : Moved common code for the replace() method of bytes and bytearray
...
to a template file.
2016-05-05 09:26:07 +03:00
Serhiy Storchaka
dd40fc3e57
Issue #26765 : Moved common code and docstrings for bytes and bytearray methods
...
to bytes_methods.c.
2016-05-04 22:23:26 +03:00
Serhiy Storchaka
7a9579c0ce
Got rid of redundand "self" parameter declarations.
...
Argument Clinic is now able to infer all needed information.
2016-05-02 13:45:20 +03:00
Serhiy Storchaka
b6a9c9761c
Issue #26778 : Fixed "a/an/and" typos in code comment, documentation and error
...
messages.
2016-04-17 09:39:28 +03:00
Serhiy Storchaka
6a7b3a77b4
Issue #26778 : Fixed "a/an/and" typos in code comment and documentation.
2016-04-17 08:32:47 +03:00
Berker Peksag
43de36d2c7
Issue #26766 : Remove redundant bytearray_format() from bytearrayobject.c
2016-04-16 01:20:47 +03:00
Serhiy Storchaka
ab479c49d3
Issue #26494 : Fixed crash on iterating exhausting iterators.
...
Affected classes are generic sequence iterators, iterators of str, bytes,
bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding
views and os.scandir() iterator.
2016-03-30 20:41:15 +03:00
Serhiy Storchaka
fbb1c5ee06
Issue #26494 : Fixed crash on iterating exhausting iterators.
...
Affected classes are generic sequence iterators, iterators of str, bytes,
bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding
views and os.scandir() iterator.
2016-03-30 20:40:02 +03:00
Victor Stinner
fac395681f
Optimize bytes.replace(b'', b'.')
...
Issue #26574 : Optimize bytes.replace(b'', b'.') and
bytearray.replace(b'', b'.'): up to 80% faster. Patch written by Josh Snider.
2016-03-21 10:38:58 +01:00
Victor Stinner
ffcf1a54d3
Oops, revert unwanted change used to create an example
...
Issue #26564 .
2016-03-15 22:49:40 +01:00
Victor Stinner
0611c26a58
On memory error, dump the memory block traceback
...
Issue #26564 : _PyObject_DebugDumpAddress() now dumps the traceback where a
memory block was allocated on memory block. Use the tracemalloc module to get
the traceback.
2016-03-15 22:22:13 +01:00
Serhiy Storchaka
ef1585eb9a
Issue #25923 : Added more const qualifiers to signatures of static and private functions.
2015-12-25 20:01:53 +02:00
Serhiy Storchaka
a9406e77fa
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:07:11 +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
413fdcea21
Issue #24821 : Refactor STRINGLIB(fastsearch_memchr_1char) and split it on
...
STRINGLIB(find_char) and STRINGLIB(rfind_char) that can be used independedly
without special preconditions.
2015-11-14 15:42:17 +02:00
Victor Stinner
f091033b14
Issue #25401 : Remove now unused hex_digit_to_int() function
2015-10-14 11:59:46 +02:00
Victor Stinner
2bf8993db9
Optimize bytes.fromhex() and bytearray.fromhex()
...
Issue #25401 : Optimize bytes.fromhex() and bytearray.fromhex(): they are now
between 2x and 3.5x faster. Changes:
* Use a fast-path working on a char* string for ASCII string
* Use a slow-path for non-ASCII string
* Replace slow hex_digit_to_int() function with a O(1) lookup in
_PyLong_DigitValue precomputed table
* Use _PyBytesWriter API to handle the buffer
* Add unit tests to check the error position in error messages
2015-10-14 11:25:33 +02:00
Victor Stinner
772b2b09f2
Optimize bytearray % args
...
Issue #25399 : Don't create temporary bytes objects: modify _PyBytes_Format() to
create work directly on bytearray objects.
* Rename _PyBytes_Format() to _PyBytes_FormatEx() just in case if something
outside CPython uses it
* _PyBytes_FormatEx() now uses (char*, Py_ssize_t) for the input string, so
bytearray_format() doesn't need tot create a temporary input bytes object
* Add use_bytearray parameter to _PyBytes_FormatEx() which is passed to
_PyBytesWriter, to create a bytearray buffer instead of a bytes buffer
Most formatting operations are now between 2.5 and 5 times faster.
2015-10-14 09:56:53 +02:00
Serhiy Storchaka
d92d4efe3d
Issue #23573 : Restored optimization of bytes.rfind() and bytearray.rfind()
...
for single-byte argument on Linux.
2015-07-20 22:58:02 +03:00
Serhiy Storchaka
bc9e75ed02
Issue #24467 : Fixed possible buffer over-read in bytearray. The bytearray
...
object now always allocates place for trailing null byte and it's buffer now
is always null-terminated.
2015-06-29 21:18:01 +03:00
Serhiy Storchaka
7b6e3b91f5
Issue #24467 : Fixed possible buffer over-read in bytearray. The bytearray
...
object now always allocates place for trailing null byte and it's buffer now
is always null-terminated.
2015-06-29 21:14:06 +03:00
Serhiy Storchaka
ac5569b1fa
Issue #24115 : Update uses of PyObject_IsTrue(), PyObject_Not(),
...
PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains()
to check for and handle errors correctly.
2015-05-30 17:48:19 +03:00
Serhiy Storchaka
fa494fd883
Issue #24115 : Update uses of PyObject_IsTrue(), PyObject_Not(),
...
PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains()
to check for and handle errors correctly.
2015-05-30 17:45:22 +03:00
Serhiy Storchaka
8b2e8b6cce
Specify default values of semantic booleans in Argument Clinic generated signatures as booleans.
2015-05-30 11:30:39 +03:00
Antoine Pitrou
ef64847f71
Issue #23985 : Fix a possible buffer overrun when deleting a slice from the front of a bytearray and then appending some other bytes data.
...
Patch by Martin Panter.
2015-05-19 20:55:42 +02:00
Antoine Pitrou
2545411e28
Issue #23985 : Fix a possible buffer overrun when deleting a slice from the front of a bytearray and then appending some other bytes data.
...
Patch by Martin Panter.
2015-05-19 20:52:27 +02:00
Gregory P. Smith
8cb6569fe1
Implements issue #9951 : Adds a hex() method to bytes, bytearray, & memoryview.
...
Also updates a few internal implementations of the same thing to use the
new built-in code.
Contributed by Arnon Yaari.
2015-04-25 23:22:26 +00:00
Christian Heimes
4e25913f9f
Remove local dead code. In both blocks dir is always greater 0.
2015-04-18 05:54:02 +02:00
Larry Hastings
89964c48d1
Issue #23944 : Argument Clinic now wraps long impl prototypes at column 78.
2015-04-14 18:07:59 -04:00
Serhiy Storchaka
1009bf18b3
Issue #23501 : Argumen Clinic now generates code into separate files by default.
2015-04-03 23:53:51 +03:00
Victor Stinner
dabbfe7b30
Issue #23573 : Fix bytes.rfind() and bytearray.rfind() on Windows
...
Windows has no memrchr() function.
This change is only a workaround, the optimization must be reenabled on other
platforms.
2015-03-25 03:16:32 +01:00
Serhiy Storchaka
d9d769fcdd
Issue #23573 : Increased performance of string search operations (str.find,
...
str.index, str.count, the in operator, str.split, str.partition) with
arguments of different kinds (UCS1, UCS2, UCS4).
2015-03-24 21:55:47 +02:00
Stefan Krah
5178d91be0
Issue #14203 : Remove obsolete support for view==NULL in PyBuffer_FillInfo()
...
and bytearray_getbuffer(). Both functions now raise BufferError in that
case.
2015-02-03 16:57:21 +01: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
Ethan Furman
b95b56150f
Issue20284: Implement PEP461
2015-01-23 20:05:18 -08:00
Antoine Pitrou
8a03896cac
Issue #22335 : Fix crash when trying to enlarge a bytearray to 0x7fffffff bytes on a 32-bit platform.
2014-11-02 18:41:56 +01:00
Antoine Pitrou
cc23154d02
Issue #22335 : Fix crash when trying to enlarge a bytearray to 0x7fffffff bytes on a 32-bit platform.
2014-11-02 18:40:09 +01:00
R David Murray
861470c836
#16518 : Bring error messages in harmony with docs ("bytes-like object")
...
Some time ago we changed the docs to consistently use the term 'bytes-like
object' in all the contexts where bytes, bytearray, memoryview, etc are used.
This patch (by Ezio Melotti) completes that work by changing the error
messages that previously reported that certain types did "not support the
buffer interface" to instead say that a bytes-like object is required. (The
glossary entry for bytes-like object references the discussion of the buffer
protocol in the docs.)
2014-10-05 11:47:01 -04:00
Terry Jan Reedy
ffff1440d1
Issue #22077 : Improve index error messages for bytearrays, bytes, lists, and
...
tuples by adding 'or slices'. Added ', not <typename' for bytearrays.
Original patch by Claudiu Popa.
2014-08-02 01:30:37 -04:00
Martin v. Löwis
0efea322a9
Rerun AC, silence pointer conversion warnings.
2014-07-27 17:29:17 +02:00
Martin v. Löwis
7252a6e81e
Issue #20179 : Apply Argument Clinic to bytes and bytearray.
...
Patch by Tal Einat.
2014-07-27 16:25:09 +02:00
Victor Stinner
2bc4d95bb6
Issue #21233 : Revert bytearray(int) optimization using calloc()
2014-06-02 22:22:42 +02:00
Victor Stinner
db067af12a
Issue #21233 : Add new C functions: PyMem_RawCalloc(), PyMem_Calloc(),
...
PyObject_Calloc(), _PyObject_GC_Calloc(). bytes(int) and bytearray(int) are now
using ``calloc()`` instead of ``malloc()`` for large objects which is faster
and use less memory (until the bytearray buffer is filled with data).
2014-05-02 22:31:14 +02:00
Kristján Valur Jónsson
c5cc5011ac
Make the various iterators' "setstate" sliently and consistently clip the
...
index. This avoids the possibility of setting an iterator to an invalid
state.
2014-03-05 15:23:07 +00:00
Kristján Valur Jónsson
25dded041f
Make the various iterators' "setstate" sliently and consistently clip the
...
index. This avoids the possibility of setting an iterator to an invalid
state.
2014-03-05 13:47:57 +00:00
Victor Stinner
8455723cfb
Close #19568 : Fix bytearray_setslice_linear(), fix handling of
...
PyByteArray_Resize() failure: leave the bytearray object in an consistent state.
If growth < 0, handling the memory allocation failure is tricky here because
the bytearray object has already been modified. If lo != 0, the operation is
completed, but a MemoryError is still raised and the memory block is not
shrinked. If lo == 0, the bytearray is restored in its previous state and a
MemoryError is raised.
2013-11-21 12:29:51 +01:00
Ezio Melotti
745d54d2fa
#17806 : Added keyword-argument support for "tabsize" to str/bytes.expandtabs().
2013-11-16 19:10:57 +02:00
Antoine Pitrou
5b72075387
Hopefully fix Windows compilation error following 499a96611baa
2013-10-05 21:24:10 +02:00
Antoine Pitrou
5df8a8a1fd
Issue #19087 : Improve bytearray allocation in order to allow cheap popping of data at the front (slice deletion).
2013-10-05 21:12:18 +02:00
Antoine Pitrou
9ed5f27266
Issue #18722 : Remove uses of the "register" keyword in C code.
2013-08-13 20:18:52 +02:00
Christian Heimes
6895947570
Propagate error when PyByteArray_Resize() fails in bytearray_translate()
...
CID 715334
2013-07-21 02:04:44 +02:00
Christian Heimes
c731bbe665
Propagate error when PyByteArray_Resize() fails in bytearray_translate()
...
CID 715334
2013-07-21 02:04:35 +02:00
Christian Heimes
e9d08cf450
Fix compilation on Windows
2012-11-03 23:08:27 +01:00
Christian Heimes
d081fbba58
Fix compilation on Windows
2012-11-03 23:08:18 +01:00
Christian Heimes
6d26ade920
Fix compilation on Windows
2012-11-03 23:07:59 +01:00
Ezio Melotti
212843b29f
#8401 : merge with 3.3.
2012-11-03 21:24:47 +02:00
Ezio Melotti
7376801f61
#8401 : merge with 3.2.
2012-11-03 21:22:41 +02:00
Ezio Melotti
c64bcbec4b
#8401 : assigning an int to a bytearray slice (e.g. b[3:4] = 5) now raises an error.
2012-11-03 21:19:06 +02:00
Antoine Pitrou
cfc22b4a9b
Issue #15958 : bytes.join and bytearray.join now accept arbitrary buffer objects.
2012-10-16 21:07:23 +02:00
Armin Ronacher
aa9a79d279
Issue #16148 : implemented PEP 424
2012-10-06 14:03:24 +02:00
Stefan Krah
7d12d9df13
Issue #12834 : Fix PyBuffer_ToContiguous() for non-contiguous arrays.
2012-07-28 12:25:55 +02:00
Antoine Pitrou
a701388de1
Rename _PyIter_GetBuiltin to _PyObject_GetBuiltin, and do not include it in the stable ABI.
2012-04-05 00:04:20 +02:00
Kristján Valur Jónsson
31668b8f7a
Issue #14288 : Serialization support for builtin iterators.
2012-04-03 10:49:41 +00:00
Antoine Pitrou
29b964d0dd
Issue #13019 : Fix potential reference leaks in bytearray.extend().
...
Patch by Suman Saha.
2012-04-01 16:08:11 +02:00
Antoine Pitrou
58bb82e7b4
Issue #13019 : Fix potential reference leaks in bytearray.extend().
...
Patch by Suman Saha.
2012-04-01 16:05:46 +02:00
Ezio Melotti
cda6b6d60d
#14081 : The sep and maxsplit parameter to str.split, bytes.split, and bytearray.split may now be passed as keyword arguments.
2012-02-26 09:39:55 +02:00
Victor Stinner
bb2e9c477d
Issue #11231 : Fix bytes and bytearray docstrings
...
Patch written by Brice Berna.
2011-12-17 23:18:07 +01:00
Victor Stinner
e010fc029d
Issue #11231 : Fix bytes and bytearray docstrings
...
Patch written by Brice Berna.
2011-12-17 23:18:43 +01:00
Antoine Pitrou
b0e1f8b38b
Issue #13503 : Use a more efficient reduction format for bytearrays with
...
pickle protocol >= 3. The old reduction format is kept with older
protocols in order to allow unpickling under Python 2.
Patch by Irmen de Jong.
2011-12-05 20:40:08 +01:00
Antoine Pitrou
39aba4f563
Use the small object allocator for small bytearrays
2011-11-12 21:15:28 +01:00
Antoine Pitrou
ac65d96777
Issue #12170 : The count(), find(), rfind(), index() and rindex() methods
...
of bytes and bytearray objects now accept an integer between 0 and 255
as their first argument. Patch by Petri Lehtinen.
2011-10-20 23:54:17 +02:00
Martin v. Löwis
bd928fef42
Rename _Py_identifier to _Py_IDENTIFIER.
2011-10-14 10:20:37 +02:00