Commit graph

234 commits

Author SHA1 Message Date
Miss Islington (bot)
db98e0bb12
[3.14] gh-71339: Use new assertion methods in tests (GH-129046) (GH-134498)
(cherry picked from commit 2602d8ae98)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-22 10:42:50 +00:00
Ageev Maxim
05557788f3
gh-131015: Add test for bytes formatting errors (#131881)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-05 10:30:16 +02:00
Ageev Maxim
7c3692fe27
gh-130928: Fix error message during bytes formatting for the 'i' flag (#130967) 2025-03-24 22:07:03 +03:00
Victor Stinner
73ab9e2ede
gh-131152: Remove unused imports from tests (#131153) 2025-03-13 10:55:23 +01:00
Daniel Pope
e0637cebe5
gh-129349: Accept bytes in bytes.fromhex()/bytearray.fromhex() (#129844)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-12 11:40:11 +01:00
Tomasz Pytel
e85f81f430
gh-129107: fix thread safety of bytearray where two critical sections are needed (#130227) 2025-02-27 20:29:58 +05:30
Tomasz Pytel
1b6bef8086
gh-129107: make bytearray iterator thread safe (#130096)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-02-19 15:42:45 +05:30
AN Long
798f8d3ea9
Replace non-breaking spaces with normal spaces (#130116)
Using normal spaces in place of non-breaking spaces.
2025-02-16 09:33:14 +08:00
Tomasz Pytel
a05433f24a
gh-129107: make bytearray thread safe (#129108)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-02-15 07:19:42 +00:00
Cody Maloney
5fb019fc29
gh-129559: Add bytearray.resize() (GH-129560)
Add bytearray.resize() which wraps PyByteArray_Resize.

Make negative size passed to resize exception/error rather than crash in optimized builds.
2025-02-05 11:33:17 -08:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి)
c33b6fbf35
gh-127740: Add some more tests for earlier PR #127756 (#127818) 2024-12-12 02:18:12 +00:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి)
db9bea0386
gh-127740: For odd-length input to bytes.fromhex(...) change the error message to ValueError: fromhex() arg must be of even length (#127756) 2024-12-11 08:35:17 +01:00
Victor Stinner
039d20ae54
gh-116417: Move limited C API abstract.c tests to _testlimitedcapi (#116986)
Split abstract.c and float.c tests of _testcapi into two parts:
limited C API tests in _testlimitedcapi and non-limited C API tests
in _testcapi.

Update test_bytes and test_class.
2024-03-19 10:44:13 +00:00
Jay Ting
948acd6ed8
gh-115323: Add meaningful error message for using bytearray.extend with str (#115332)
Perform str check after TypeError is raised
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2024-02-24 18:34:45 -05:00
Serhiy Storchaka
2223899adc
gh-104231: Add more tests for str(), repr(), ascii(), and bytes() (GH-112551) 2023-11-30 17:22:04 +02:00
Serhiy Storchaka
16c9415fba
gh-107178: Add the C API tests for the Abstract Objects Layer (GH-107179)
Cover all the Mapping Protocol, almost all the Sequence Protocol
(except PySequence_Fast) and a part of the Object Protocol.

Move existing tests to Lib/test/test_capi/test_abstract.py and
Modules/_testcapi/abstract.c.

Add also tests for PyDict C API.
2023-08-07 18:51:43 +03:00
Michael Droettboom
dfcdee4a18
gh-94808: Add coverage for bytesarray_setitem (#95802) 2022-10-10 08:28:41 -07:00
Michael Droettboom
dde15f5879
gh-94808: Improve coverage of _PyBytes_FormatEx (GH-95895)
There were two specific areas not covered:

- %(name) syntax
- %*s syntax

Automerge-Triggered-By: GH:iritkatriel
2022-09-07 04:51:50 -07:00
Brandt Bucher
f36589510b
GH-91153: Handle mutating __index__ methods in bytearray item assignment (GH-94891) 2022-07-19 09:42:40 -07:00
Serhiy Storchaka
884eba3c76
bpo-26579: Add object.__getstate__(). (GH-2821)
Copying and pickling instances of subclasses of builtin types
bytearray, set, frozenset, collections.OrderedDict, collections.deque,
weakref.WeakSet, and datetime.tzinfo now copies and pickles instance attributes
implemented as slots.
2022-04-06 20:00:14 +03:00
Christian Heimes
e73283a20f
bpo-45668: Fix PGO tests without test extensions (GH-29315) 2021-11-01 11:14:53 +01:00
Mark Dickinson
ae5259171b
Fix bytes.__bytes__ to not truncate at a zero byte (GH-27902) 2021-08-23 15:24:12 +01:00
Dong-hee Na
24b63c695a
bpo-24234: Implement bytes.__bytes__ (GH-27901) 2021-08-23 19:01:51 +09:00
Nikita Sobolev
a2ce538e16
bpo-44891: Tests id preserving on * 1 for str and bytes (GH-27745)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-08-13 12:36:22 +02:00
Tobias Holl
61d8c54f43
bpo-42924: Fix incorrect copy in bytearray_repeat (GH-24208)
Before, using the * operator to repeat a bytearray would copy data from the start of
the internal buffer (ob_bytes) and not from the start of the actual data (ob_start).
2021-01-13 18:16:40 +02:00
Ronald Oussoren
41761933c1
bpo-41100: Support macOS 11 and Apple Silicon (GH-22855)
Co-authored-by:  Lawrence D’Anna <lawrence_danna@apple.com>

* Add support for macOS 11 and Apple Silicon (aka arm64)
   
  As a side effect of this work use the system copy of libffi on macOS, and remove the vendored copy

* Support building on recent versions of macOS while deploying to older versions

  This allows building installers on macOS 11 while still supporting macOS 10.9.
2020-11-08 10:05:27 +01:00
Hai Shi
fcce8c649a
bpo-40275: Use new test.support helper submodules in tests (GH-21772) 2020-08-07 23:55:35 +02:00
Hai Shi
a089d21df1
bpo-40275: Use new test.support helper submodules in tests (GH-21315) 2020-07-06 11:15:08 +02:00
Bruce Merry
d07d9f4c43
bpo-36051: Drop GIL during large bytes.join() (GH-17757)
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.
2020-01-29 16:09:24 +09:00
Sergey Fedoseev
92709a263e bpo-37840: Fix handling of negative indices in bytearray_getitem() (GH-15250) 2019-09-09 09:28:34 -07:00
Victor Stinner
22eb689cf3
bpo-37388: Development mode check encoding and errors (GH-14341)
In development mode and in debug build, encoding and errors arguments
are now checked on string encoding and decoding operations. Examples:
open(), str.encode() and bytes.decode().

By default, for best performances, the errors argument is only
checked at the first encoding/decoding error, and the encoding
argument is sometimes ignored for empty strings.
2019-06-26 00:51:05 +02:00
Gregory P. Smith
0c2f930564
bpo-22385: Support output separators in hex methods. (#13578)
* bpo-22385: Support output separators in hex methods.

Also in binascii.hexlify aka b2a_hex.

The underlying implementation behind all hex generation in CPython uses the
same pystrhex.c implementation.  This adds support to bytes, bytearray,
and memoryview objects.

The binascii module functions exist rather than being slated for deprecation
because they return bytes rather than requiring an intermediate step through a
str object.

This change was inspired by MicroPython which supports sep in its binascii
implementation (and does not yet support the .hex methods).

https://bugs.python.org/issue22385
2019-05-29 11:46:58 -07:00
Zackery Spytz
14514d9084 bpo-36946: Fix possible signed integer overflow when handling slices. (GH-13375)
The final addition (cur += step) may overflow, so use size_t for "cur".
"cur" is always positive (even for negative steps), so it is safe to use
size_t here.

Co-Authored-By: Martin Panter <vadmium+py@gmail.com>
2019-05-17 10:13:03 +03:00
Serhiy Storchaka
8e79e6e56f
Fix syntax warnings in tests introduced in bpo-15248. (GH-11932) 2019-02-19 13:49:09 +02:00
Serhiy Storchaka
44cc4822bb
bpo-33817: Fix _PyBytes_Resize() for empty bytes object. (GH-11516)
Add also tests for PyUnicode_FromFormat() and PyBytes_FromFormat()
with empty result.
2019-01-12 09:22:29 +02:00
Serhiy Storchaka
2c2044e789
bpo-34984: Improve error messages for bytes and bytearray constructors. (GH-9874) 2018-10-21 15:29:12 +03:00
Serhiy Storchaka
914f9a078f
bpo-34973: Fix crash in bytes constructor. (GH-9841)
Constructing bytes from mutating list could cause a crash.
2018-10-21 15:25:53 +03:00
Serhiy Storchaka
e890421e33
bpo-34974: Do not replace unexpected errors in bytes() and bytearray(). (GH-9852)
bytes and bytearray constructors converted unexpected exceptions
(e.g. MemoryError and KeyboardInterrupt) to TypeError.
2018-10-15 00:02:57 +03:00
Serhiy Storchaka
1a997eb291
Add new tests for bytes and bytearray constructors. (GH-9843)
Covered all special cases: bytes, tuple, list, differend
kinds of iterables and iterators.
2018-10-13 20:39:45 +03: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
604e74c6be bpo-20552: Use specific asserts in bytes tests (#790) 2017-03-27 12:59:07 +02:00
Xiang Zhang
b76ad5121e bpo-29714: Fix a regression that bytes format may fail when containing zero bytes inside. (GH-499) 2017-03-06 17:17:05 +08: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
Serhiy Storchaka
dd1da7f74a Issue #28927: bytes.fromhex() and bytearray.fromhex() now ignore all ASCII
whitespace, not only spaces.  Patch by Robert Xiao.
2016-12-19 18:51:37 +02:00
Serhiy Storchaka
7984bff52a Issue #28385: An error message when non-empty format spec is passed to
object.__format__ now contains the name of actual type.
2016-10-30 19:37:46 +02:00
Serhiy Storchaka
d1af5effc2 Issue #28385: An error message when non-empty format spec is passed to
object.__format__ now contains the name of actual type.
2016-10-30 19:33:54 +02:00
Serhiy Storchaka
c49a516ae9 Remove old typo.
Initially (e0b7e34b5971) it should be \udef0, but after 52a77ef069cd
(issue #3672) lone surrogates are not accepted and should be removed.
2016-09-08 15:47:27 +03: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
Guido van Rossum
97c1adf393 Anti-registration of various ABC methods.
- Issue #25958: Support "anti-registration" of special methods from
  various ABCs, like __hash__, __iter__ or __len__.  All these (and
  several more) can be set to None in an implementation class and the
  behavior will be as if the method is not defined at all.
  (Previously, this mechanism existed only for __hash__, to make
  mutable classes unhashable.)  Code contributed by Andrew Barnert and
  Ivan Levkivskyi.
2016-08-18 09:22:23 -07:00