diff --git a/AUTHORS.md b/AUTHORS.md index 92f1a4a97..778640c0d 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -85,3 +85,4 @@ - ([@alxnull](https://github.com/alxnull)) - ([@gpetrou](https://github.com/gpetrou)) - Ehsan Iran-Nejad ([@eirannejad](https://github.com/eirannejad)) +- Rolf Madsen ([@rmadsen-ks](https://github.com/rmadsen-ks)) diff --git a/src/python_tests_runner/PythonTestRunner.cs b/src/python_tests_runner/PythonTestRunner.cs index 05298997b..920219b72 100644 --- a/src/python_tests_runner/PythonTestRunner.cs +++ b/src/python_tests_runner/PythonTestRunner.cs @@ -35,6 +35,7 @@ static IEnumerable PythonTestCases() // Add the test that you want to debug here. yield return new[] { "test_indexer", "test_boolean_indexer" }; yield return new[] { "test_delegate", "test_bool_delegate" }; + yield return new[] { "test_conversion", "test_object_string_format" }; } /// diff --git a/src/runtime/PythonTypes/PyInt.cs b/src/runtime/PythonTypes/PyInt.cs index 6b3dbf210..278056345 100644 --- a/src/runtime/PythonTypes/PyInt.cs +++ b/src/runtime/PythonTypes/PyInt.cs @@ -228,7 +228,8 @@ public BigInteger ToBigInteger() public string ToString(string format, IFormatProvider formatProvider) { using var _ = Py.GIL(); - return ToBigInteger().ToString(format, formatProvider); + object val = Runtime.PyLong_AsLongLong(obj); + return val?.ToString() ?? ToBigInteger().ToString(format, formatProvider); } public override TypeCode GetTypeCode() => TypeCode.Int64; diff --git a/tests/test_conversion.py b/tests/test_conversion.py index bb686dd52..2eebbe7f8 100644 --- a/tests/test_conversion.py +++ b/tests/test_conversion.py @@ -752,3 +752,9 @@ def test_explicit_conversion(): assert int(t(123.4)) == 123 with pytest.raises(TypeError): index(t(123.4)) + +def test_object_string_format(): + from System import String + integer_value = 200 + string_value = String.Format("{0}", integer_value) + assert string_value == "200", f"{string_value} != ""200""" diff --git a/tests/test_delegate.py b/tests/test_delegate.py index 55115203c..7e2f27fed 100644 --- a/tests/test_delegate.py +++ b/tests/test_delegate.py @@ -451,3 +451,6 @@ def wrong_return_type(intValue, stringValue): # test sig mismatch, both on managed and Python side # test return wrong type + + + pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy