19 Commits

Author SHA1 Message Date
Changjoon
e5f2d2d3b9 Drop int() delegation to __trunc__ (#7703)
CPython 3.14 fully removed the long-deprecated fallback from int() to
__trunc__. Classes that want int(x) support must implement __int__ or
__index__; math.trunc(x) continues to use __trunc__.

Delete the __trunc__ branch in PyObject::try_int so a class with only
__trunc__ now reaches the existing TypeError arm, matching CPython.

Unmasks test_int.IntTestCases.test_intconversion.
2026-04-28 21:10:42 +09:00
Changjoon
9794ab7fdf Enforce int_max_str_digits on int-to-str conversions (#7688)
* Enforce int_max_str_digits on int-to-str conversions

The str-to-int direction already enforced sys.get_int_max_str_digits()
via bytes_to_int; the int-to-str direction did not. CPython 3.14 enforces
both per PEP 644.

Adds check_int_to_str_digits helper in builtins::int (bit-count fast path
+ digit upper-bound from log10(2)), wired into the four Python-level
entry points: repr, the str fast path in protocol::object, int.__format__
(decimal/n/empty spec only — binary bases x/o/b are exempt per CPython),
and the DecimalD/I/U branches of vm::cformat for both str % and bytes %.

Unmasks 8 expectedFailure tests across test_int (max_str_digits, DoS
prevention, int_from_other_bases — each mirrored in IntSubclass),
test_ast (test_repr_large_input_crash) and test_reprlib (test_numbers).
Boundary cases (4299/4300/4301 digits at limit=4300) match CPython 3.14.4.

* Skip int-to-str DoS test on platforms without time.get_clock_info

The test_denial_of_service_prevented_int_to_str regression test uses
support.Stopwatch, which calls time.get_clock_info('monotonic'). In
RustPython that function is gated to unix/windows targets only, so on
wasm32-wasip1 it surfaces as AttributeError and breaks the wasm-wasi CI.
Guard the test with skipUnless(hasattr(time, 'get_clock_info'), ...) so
it runs everywhere it can and is skipped on wasm.

Also narrow is_decimal_int_format to Number(Case::Lower): 'N' is rejected
by format_int as UnknownFormatCode, so excluding it preserves that error
path instead of intercepting it with the digit-limit check.

* Add TODO: RUSTPYTHON marker to skipUnless reason

scripts/update_lib uses TODO: RUSTPYTHON markers inside unittest
decorator reason strings to identify and migrate custom RustPython
patches across CPython library updates.

* Use expectedFailureIf for wasm get_clock_info gap

skipUnless silently hides the test forever; expectedFailureIf surfaces
unexpected success once RustPython implements time.get_clock_info on
wasm, prompting marker removal.
2026-04-27 21:41:40 +09:00
ShaharNaveh
e02e813bf8 Update _pylong.py from 3.14.3 2026-02-13 13:55:05 +09:00
Jeong, YunWon
8f7b1343bc mark and unmark successful/failing tests 2026-01-18 20:00:15 +09:00
Shahar Naveh
ceb7046bc4 Fix int respect sys.set_int_max_str_digits value (#6094) 2025-08-21 13:14:10 +09:00
ShaharNaveh
d5793e04ec Don't import unittest.mock in test_int.py 2025-07-26 17:48:07 +02:00
ShaharNaveh
73f5ceb79b Update test_int.py 2025-07-25 16:20:36 +02:00
Kangzhi Shi
59cedd2213 deprecated warnings for int 2022-05-30 07:36:07 +09:00
Jeong YunWon
64ef4916ec Update test_int.py to CPython 3.10.2 2022-03-13 03:56:48 +09:00
Jeong YunWon
6b71a89281 small int cache for int.__new__ 2020-08-08 15:17:22 +09:00
Jeong YunWon
aa899f6a1a convert skip to expectedFailure 2020-08-08 06:03:59 +09:00
Noah
dcbce354d5 Fix string repr in int invalid literal error 2020-04-28 13:35:28 -05:00
Noah
92b5d2091d Unskip int test 2020-04-27 15:03:04 -05:00
Noah
e132e2f2e7 Fix int base-0 parsing 2020-04-27 15:03:04 -05:00
Jeong YunWon
a08b4568e2 Merge pull request #1783 from youknowone/int-bytes
bytearray/memoryview/array support for int()
2020-03-08 12:27:18 +09:00
Jeong YunWon
0eaf3731e9 memoryview/array support for int() 2020-02-29 11:32:29 +09:00
Jeong YunWon
4be3a365ce non-int indexable base for int() 2020-02-29 10:07:14 +09:00
Aviv Palivoda
5622fd0704 Mark unsupported tests 2020-02-14 09:02:30 +02:00
Aviv Palivoda
df85907bf8 Add test_int from CPython 3.8 2020-02-14 09:02:23 +02:00