summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bytes.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-22385: Support output separators in hex methods. (#13578)Gregory P. Smith2019-05-291-0/+57
| | | | | | | | | | | | | | | | | | * 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
* bpo-36946: Fix possible signed integer overflow when handling slices. (GH-13375)Zackery Spytz2019-05-171-2/+3
| | | | | | | 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>
* Fix syntax warnings in tests introduced in bpo-15248. (GH-11932)Serhiy Storchaka2019-02-191-3/+5
|
* bpo-33817: Fix _PyBytes_Resize() for empty bytes object. (GH-11516)Serhiy Storchaka2019-01-121-0/+6
| | | | Add also tests for PyUnicode_FromFormat() and PyBytes_FromFormat() with empty result.
* bpo-34984: Improve error messages for bytes and bytearray constructors. ↵Serhiy Storchaka2018-10-211-0/+2
| | | | (GH-9874)
* bpo-34973: Fix crash in bytes constructor. (GH-9841)Serhiy Storchaka2018-10-211-0/+17
| | | Constructing bytes from mutating list could cause a crash.
* bpo-34974: Do not replace unexpected errors in bytes() and bytearray(). ↵Serhiy Storchaka2018-10-141-2/+16
| | | | | | | (GH-9852) bytes and bytearray constructors converted unexpected exceptions (e.g. MemoryError and KeyboardInterrupt) to TypeError.
* Add new tests for bytes and bytearray constructors. (GH-9843)Serhiy Storchaka2018-10-131-3/+43
| | | | Covered all special cases: bytes, tuple, list, differend kinds of iterables and iterators.
* bpo-20047: Make bytearray methods partition() and rpartition() rejecting (#4158)Serhiy Storchaka2017-10-281-6/+29
| | | separators that are not bytes-like objects.
* bpo-20552: Use specific asserts in bytes tests (#790)Serhiy Storchaka2017-03-271-15/+15
|
* bpo-29714: Fix a regression that bytes format may fail when containing zero ↵Xiang Zhang2017-03-061-0/+10
| | | | bytes inside. (GH-499)
* Merge 3.6INADA Naoki2017-01-061-0/+13
|\
| * Issue #29159: Fix regression in bytes(x) when x.__index__() raises Exception.INADA Naoki2017-01-061-0/+13
| |
* | Issue #28927: bytes.fromhex() and bytearray.fromhex() now ignore all ASCIISerhiy Storchaka2016-12-191-0/+8
|/ | | | whitespace, not only spaces. Patch by Robert Xiao.
* Issue #28385: An error message when non-empty format spec is passed toSerhiy Storchaka2016-10-301-0/+9
|\ | | | | | | object.__format__ now contains the name of actual type.
| * Issue #28385: An error message when non-empty format spec is passed toSerhiy Storchaka2016-10-301-0/+9
| | | | | | | | object.__format__ now contains the name of actual type.
* | Remove old typo.Serhiy Storchaka2016-09-081-1/+1
| | | | | | | | | | Initially (e0b7e34b5971) it should be \udef0, but after 52a77ef069cd (issue #3672) lone surrogates are not accepted and should be removed.
* | Issue #27506: Support bytes/bytearray.translate() delete as keyword argumentMartin Panter2016-08-271-18/+31
| | | | | | | | Patch by Xiang Zhang.
* | Anti-registration of various ABC methods.Guido van Rossum2016-08-181-0/+30
| | | | | | | | | | | | | | | | | | | | - 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.
* | Issue #27474: Unified error messages in the __contains__ method of bytes andSerhiy Storchaka2016-07-101-0/+1
| | | | | | | | | | bytearray for integers in and out of the Py_ssize_t range. Patch by Xiang Zhang.
* | Issue #27443: __length_hint__() of bytearray itearator no longer returnSerhiy Storchaka2016-07-031-0/+10
|\ \ | |/ | | | | negative integer for resized bytearray.
| * Issue #27443: __length_hint__() of bytearray itearator no longer returnSerhiy Storchaka2016-07-031-0/+10
| | | | | | | | negative integer for resized bytearray.
* | Issue #27007: The fromhex() class methods of bytes and bytearray subclassesSerhiy Storchaka2016-07-011-1/+26
| | | | | | | | now return an instance of corresponding subclass.
* | Issue #27039: Fixed bytearray.remove() for values greater than 127.Serhiy Storchaka2016-05-161-0/+7
|\ \ | |/ | | | | Based on patch by Joe Jevnik.
| * Issue #27039: Fixed bytearray.remove() for values greater than 127.Serhiy Storchaka2016-05-161-0/+7
| | | | | | | | Patch by Joe Jevnik.
* | Make bytes and bytearray subclass tests compatible with base types tests.Serhiy Storchaka2016-05-121-15/+17
|\ \ | |/
| * Make bytes and bytearray subclass tests compatible with base types tests.Serhiy Storchaka2016-05-121-15/+17
| |
| * Issue #26764: Bacported tests for bytes formatting.Serhiy Storchaka2016-04-151-26/+11
| |
* | Issue #26766: Fix _PyBytesWriter_Finish()Victor Stinner2016-04-151-2/+2
| | | | | | | | | | | | | | 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.
* | Issue #26764: Fixed SystemError in bytes.__rmod__.Serhiy Storchaka2016-04-151-26/+11
| |
* | Issue #26712: Merge string_tests cleanup from 3.5Martin Panter2016-04-101-87/+4
|\ \ | |/
| * Issue #26712: Unify (r)split, (l/r)strip tests into string_testsMartin Panter2016-04-101-87/+4
| | | | | | | | This eliminates a few redundant test cases.
* | Issue #26257: Merge buffer_tests cleanup from 3.5Martin Panter2016-04-081-9/+6
|\ \ | |/
| * Issue #26257: Eliminate buffer_tests.py and fix ByteArrayAsStringTestMartin Panter2016-04-061-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Issue #26492: Added additional tests for exhausted iterators of mutable ↵Serhiy Storchaka2016-03-301-0/+2
|\ \ | |/ | | | | sequences.
| * Issue #26492: Added additional tests for exhausted iterators of mutable ↵Serhiy Storchaka2016-03-301-0/+2
| | | | | | | | sequences.
* | Issue #26494: Fixed crash on iterating exhausting iterators.Serhiy Storchaka2016-03-301-0/+4
|\ \ | |/ | | | | | | | | Affected classes are generic sequence iterators, iterators of str, bytes, bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding views and os.scandir() iterator.
| * Issue #26494: Fixed crash on iterating exhausting iterators.Serhiy Storchaka2016-03-301-0/+4
| | | | | | | | | | | | Affected classes are generic sequence iterators, iterators of str, bytes, bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding views and os.scandir() iterator.
* | Issue #26015: Added new tests for pickling iterators of mutable sequences.Serhiy Storchaka2016-03-061-3/+39
|\ \ | |/
| * Issue #26015: Added new tests for pickling iterators of mutable sequences.Serhiy Storchaka2016-03-061-3/+39
| |
* | Issue #19587: Merge test_bytes cleanup from 3.5Martin Panter2016-02-021-13/+0
|\ \ | |/
| * Issue #19587: Remove masked and redundant tests in test_bytesMartin Panter2016-02-021-13/+0
| | | | | | | | | | | | | | | | * 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
* | Issue #25766: Special method __bytes__() now works in str subclasses.Serhiy Storchaka2015-12-201-0/+6
|\ \ | |/
| * Issue #25766: Special method __bytes__() now works in str subclasses.Serhiy Storchaka2015-12-201-0/+6
| |
* | Issue #24731: Fixed crash on converting objects with special methodsSerhiy Storchaka2015-11-251-0/+11
|\ \ | |/ | | | | | | __bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
| * Issue #24731: Fixed crash on converting objects with special methodsSerhiy Storchaka2015-11-251-0/+11
| |\ | | | | | | | | | | | | __bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
| | * Issue #24731: Fixed crash on converting objects with special methodsSerhiy Storchaka2015-11-251-0/+11
| | | | | | | | | | | | | | | __bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
* | | test_bytes: new try to fix test on '%p' formatter on WindowsVictor Stinner2015-10-141-6/+16
| | |
* | | Optimize bytes.fromhex() and bytearray.fromhex()Victor Stinner2015-10-141-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Fix test_bytes on WindowsVictor Stinner2015-10-141-4/+7
| | | | | | | | | | | | | | | On Windows, sprintf("%p", 0xabcdef) formats hexadecimal in uppercase and pad to 16 characters (on 64-bit system) with zeros.