micropython/tests/cpydiff
Angus Gratton c97d3534dc py/objint: Fix int.to_bytes() buffer size checks.
* No longer overflows if byte size is 0 (closes #13041)
* Raises OverflowError in any case where number won't fit into byte length
  (Now matches CPython, previously MicroPython would return a truncated
  bytes object.)
* Document that micropython int.to_bytes() doesn't implement the optional
  signed kwarg, but will behave as if signed=True when the integer is
  negative (this is the current behaviour). Add tests for this also.

Requires changes for small ints, MPZ large ints, and "long long" large
ints.

Adds a new set of unit tests for ints between 32 and 64 bits to increase
coverage of "long long" large ints, which are otherwise untested.

Tested on unix port (64 bit small ints, MPZ long ints) and Zephyr STM32WB
board (32 bit small ints, long long large ints).

Untested on a port whose native format is big endian (don't have one at
hand).

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-10 13:52:29 +10:00
..
modules tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
modules2/subpkg tests/cpydiff/core_import_split_ns_pkgs: Test for split namespace packages. 2017-05-03 17:16:19 +03:00
modules3 tests/cpydiff: Add cpydiff test for __all__ used in imported package. 2020-05-02 17:41:04 +10:00
builtin_next_arg2.py tests/cpydiff: Fix markup where "`" (xref) was used instead of "``" (code). 2017-12-03 15:32:09 +02:00
core_class_delnotimpl.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
core_class_mro.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
core_class_name_mangling.py tests/cpydiff: Add new CPy diff test for class name mangling. 2024-02-21 11:42:35 +11:00
core_class_supermultiple.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
core_class_superproperty.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
core_fstring_concat.py tests/cpydiff: Clarify f-string diffs regarding concatenation. 2021-11-25 22:09:59 +11:00
core_fstring_parser.py py/lexer: Support nested [] and {} characters within f-string params. 2021-11-25 21:50:58 +11:00
core_fstring_raw.py py: Implement partial PEP-498 (f-string) support. 2021-08-14 16:58:40 +10:00
core_fstring_repr.py py/lexer: Allow conversion specifiers in f-strings (e.g. !r). 2023-06-14 19:11:04 +10:00
core_function_argcount.py tests/cpydiff/core_arguments: Move under Functions subsection. 2017-07-09 13:36:28 +03:00
core_function_moduleattr.py tests/cpydiff: Add test and workaround for function.__module__ attr. 2021-05-16 11:06:46 +10:00
core_function_userattr.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
core_generator_noexit.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
core_import_all.py tests/cpydiff: Add cpydiff test for __all__ used in imported package. 2020-05-02 17:41:04 +10:00
core_import_path.py all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
core_import_split_ns_pkgs.py all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
core_locals.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
core_locals_eval.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
module_array_comparison.py py/objarray: Prohibit comparison of mismatching types. 2021-05-13 22:16:14 +10:00
module_array_constructor.py tests/cpydiff: Add test for array constructor with overflowing value. 2021-06-13 10:30:14 +10:00
modules_array_containment.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
modules_array_deletion.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
modules_array_subscrstep.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
modules_deque.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
modules_json_nonserializable.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
modules_os_environ.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
modules_os_getenv.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
modules_random_getrandbits.py extmod/modurandom: Add error message when getrandbits has bad value. 2021-05-30 16:41:30 +10:00
modules_random_randint.py all: Update Python formatting to latest Black version 22.1.0. 2022-02-02 16:49:55 +11:00
modules_struct_fewargs.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
modules_struct_manyargs.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
modules_struct_whitespace_in_format.py tests/cpydiff/modules_struct_whitespace_in_format: Run black. 2021-07-06 18:19:55 -05:00
modules_sys_stdassign.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
syntax_arg_unpacking.py py/runtime: Allow multiple *args in a function call. 2022-03-31 16:59:30 +11:00
syntax_assign_expr.py tests/cpydiff: Add CPy diff test for assignment expression behaviour. 2020-06-16 22:06:47 +10:00
syntax_spaces.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
syntax_unicode_nameesc.py tests/cpydiff: Add initial set of tests for uPy-CPython differences. 2017-02-20 16:50:34 +11:00
types_bytearray_sliceassign.py tests/cpydiff: Add initial set of tests for uPy-CPython differences. 2017-02-20 16:50:34 +11:00
types_bytes_format.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_bytes_keywords.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_bytes_subscrstep.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_dict_keys_set.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_exception_attrs.py py/objexcept: Support errno attribute on OSError exceptions. 2021-04-23 22:03:46 +10:00
types_exception_chaining.py tests/cpydiff: Add initial set of tests for uPy-CPython differences. 2017-02-20 16:50:34 +11:00
types_exception_instancevar.py tests/cpydiff/: Improve wording, add more workarounds. 2017-07-09 14:33:55 +03:00
types_exception_loops.py tests/cpydiff/: Improve wording, add more workarounds. 2017-07-09 14:33:55 +03:00
types_exception_subclassinit.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_float_implicit_conversion.py tests/cpydiff: Fix formatting of code snippet to use double quotes. 2022-07-29 12:23:05 +10:00
types_float_rounding.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_int_bit_length.py extmod/modurandom: Add error message when getrandbits has bad value. 2021-05-30 16:41:30 +10:00
types_int_subclassconv.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_int_to_bytes.py py/objint: Fix int.to_bytes() buffer size checks. 2024-04-10 13:52:29 +10:00
types_list_delete_subscrstep.py tests/cpydiff/: Improve wording, add more workarounds. 2017-07-09 14:33:55 +03:00
types_list_store_noniter.py tests/cpydiff: Add a test for storing iterable to a list slice. 2017-02-20 17:22:12 +11:00
types_list_store_subscrstep.py tests/cpydiff/: Improve wording, add more workarounds. 2017-07-09 14:33:55 +03:00
types_str_endswith.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_str_formatsubscr.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_str_keywords.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_str_ljust_rjust.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_str_rsplitnone.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_str_subscrstep.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
types_tuple_subscrstep.py tests/cpydiff: Add initial set of tests for uPy-CPython differences. 2017-02-20 16:50:34 +11:00