Skip to content

Commit 5861cd0

Browse files
dc366slozier
andauthored
Replace sys.long_info with sys.int_info (#1138)
* Replace sys.long_info with sys.int_info * Update Src/IronPython/Modules/sys.cs Correct PythonType name Co-authored-by: slozier <[email protected]>
1 parent 04117d8 commit 5861cd0

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Src/IronPython/Modules/sys.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ public int quiet {
406406

407407
#endregion
408408

409-
// These values are based on the .NET 2 BigInteger in Microsoft.Scripting.Math
410-
public static longinfo long_info = new longinfo(32, 4);
409+
// These values are based on the .NET BigInteger in System.Numerics.BigInteger
410+
public static intinfo int_info = new intinfo(32, 4);
411411

412-
[PythonType("long_info"), PythonHidden]
413-
public class longinfo : PythonTuple {
414-
internal longinfo(int bits_per_digit, int sizeof_digit)
412+
[PythonType("int_info"), PythonHidden]
413+
public class intinfo : PythonTuple {
414+
internal intinfo(int bits_per_digit, int sizeof_digit)
415415
: base(new object[] { bits_per_digit, sizeof_digit }) {
416416

417417
this.bits_per_digit = bits_per_digit;
@@ -426,7 +426,7 @@ internal longinfo(int bits_per_digit, int sizeof_digit)
426426
public const int n_unnamed_fields = 0;
427427

428428
public override string __repr__(CodeContext context) {
429-
return $"sys.long_info(bits_per_digit={bits_per_digit}, sizeof_digit={sizeof_digit})";
429+
return $"sys.int_info(bits_per_digit={bits_per_digit}, sizeof_digit={sizeof_digit})";
430430
}
431431
}
432432

Src/StdLib/Lib/test/test_sys.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,13 @@ def test_attributes(self):
406406
self.assertEqual(len(sys.float_info), 11)
407407
self.assertEqual(sys.float_info.radix, 2)
408408
self.assertEqual(len(sys.int_info), 2)
409-
self.assertTrue(sys.int_info.bits_per_digit % 5 == 0)
409+
410+
# ironpython-specific integer representation https://github.com/IronLanguages/ironpython3/issues/974
411+
if sys.implementation.name == "ironpython":
412+
self.assertTrue(sys.int_info.bits_per_digit == 32)
413+
else:
414+
self.assertTrue(sys.int_info.bits_per_digit % 5 == 0)
415+
410416
self.assertTrue(sys.int_info.sizeof_digit >= 1)
411417
self.assertEqual(type(sys.int_info.bits_per_digit), int)
412418
self.assertEqual(type(sys.int_info.sizeof_digit), int)

0 commit comments

Comments
 (0)