Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

1990 py int to string fix#1991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsAUTHORS.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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))
1 change: 1 addition & 0 deletionssrc/python_tests_runner/PythonTestRunner.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@ static IEnumerable<string[]> 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" };
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletionsrc/runtime/PythonTypes/PyInt.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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;
Expand Down
6 changes: 6 additions & 0 deletionstests/test_conversion.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"""
3 changes: 3 additions & 0 deletionstests/test_delegate.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -451,3 +451,6 @@ def wrong_return_type(intValue, stringValue):
# test sig mismatch, both on managed and Python side

# test return wrong type




[8]ページ先頭

©2009-2025 Movatter.jp