| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
| |
Add also tests for PyUnicode_FromFormat() and PyBytes_FromFormat()
with empty result.
|
|
|
|
| |
(GH-9874)
|
|
|
| |
Constructing bytes from mutating list could cause a crash.
|
|
|
|
|
|
|
| |
(GH-9852)
bytes and bytearray constructors converted unexpected exceptions
(e.g. MemoryError and KeyboardInterrupt) to TypeError.
|
|
|
|
| |
Covered all special cases: bytes, tuple, list, differend
kinds of iterables and iterators.
|
|
|
| |
separators that are not bytes-like objects.
|
| |
|
|
|
|
| |
bytes inside. (GH-499)
|
|\ |
|
| | |
|
|/
|
|
| |
whitespace, not only spaces. Patch by Robert Xiao.
|
|\
| |
| |
| | |
object.__format__ now contains the name of actual type.
|
| |
| |
| |
| | |
object.__format__ now contains the name of actual type.
|
| |
| |
| |
| |
| | |
Initially (e0b7e34b5971) it should be \udef0, but after 52a77ef069cd
(issue #3672) lone surrogates are not accepted and should be removed.
|
| |
| |
| |
| | |
Patch by Xiang Zhang.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- 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.
|
| |
| |
| |
| |
| | |
bytearray for integers in and out of the Py_ssize_t range.
Patch by Xiang Zhang.
|
|\ \
| |/
| |
| | |
negative integer for resized bytearray.
|
| |
| |
| |
| | |
negative integer for resized bytearray.
|
| |
| |
| |
| | |
now return an instance of corresponding subclass.
|
|\ \
| |/
| |
| | |
Based on patch by Joe Jevnik.
|
| |
| |
| |
| | |
Patch by Joe Jevnik.
|
|\ \
| |/ |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
Return a bytearray object when bytearray is requested and when the small buffer
is used.
Fix also test_bytes: bytearray%args must return a bytearray type.
|
| | |
|
|\ \
| |/ |
|
| |
| |
| |
| | |
This eliminates a few redundant test cases.
|
|\ \
| |/ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
ByteArrayAsStringTest.fixtype() was converting test data to bytes, not byte-
array, therefore many of the test cases inherited in this class were not
actually being run on the bytearray type.
The tests in buffer_tests.py were redundant with methods in string_tests
.MixinStrUnicodeUserStringTest and string_tests.CommonTest. These methods are
now moved into string_tests.BaseTest, where they will also get run for bytes
and bytearray.
This change also moves test_additional_split(), test_additional_rsplit(), and
test_strip() from CommonTest to BaseTest, meaning these tests are now run for
bytes and bytearray. I plan to eliminate redundancies with existing tests in
test_bytes.py soon.
|
|\ \
| |/
| |
| | |
sequences.
|
| |
| |
| |
| | |
sequences.
|
|\ \
| |/
| |
| |
| |
| | |
Affected classes are generic sequence iterators, iterators of str, bytes,
bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding
views and os.scandir() iterator.
|
| |
| |
| |
| |
| |
| | |
Affected classes are generic sequence iterators, iterators of str, bytes,
bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding
views and os.scandir() iterator.
|
|\ \
| |/ |
|
| | |
|
|\ \
| |/ |
|
| |
| |
| |
| |
| |
| |
| |
| | |
* test_contains() did not override anything
* test_expandtabs/upper/lower() in FixedStringTest were masking usable tests
in string_tests. These tests now get run for bytearray() and bytes().
* test_expandtabs/upper/lower() in buffer_tests were only run on bytearray()
and are redundant with string_tests
|
|\ \
| |/ |
|
| | |
|
|\ \
| |/
| |
| |
| | |
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
|
| |\
| | |
| | |
| | |
| | | |
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
|
| | |
| | |
| | |
| | |
| | | |
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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
|
| | |
| | |
| | |
| | |
| | | |
On Windows, sprintf("%p", 0xabcdef) formats hexadecimal in uppercase and pad to
16 characters (on 64-bit system) with zeros.
|