where T : Enum
{
[ForbidPythonThreads]
#pragma warning disable IDE1006 // Naming Styles - must match Python
- public static PyInt __int__(T value)
+ public static PyInt __index__(T value)
#pragma warning restore IDE1006 // Naming Styles
=> typeof(T).GetEnumUnderlyingType() == typeof(UInt64)
? new PyInt(Convert.ToUInt64(value))
: new PyInt(Convert.ToInt64(value));
+ [ForbidPythonThreads]
+#pragma warning disable IDE1006 // Naming Styles - must match Python
+ public static PyInt __int__(T value) => __index__(value);
+#pragma warning restore IDE1006 // Naming Styles
}
}
diff --git a/tests/conftest.py b/tests/conftest.py
index fcd1d224a..e61e3680e 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -53,10 +53,12 @@ def pytest_configure(config):
runtime_params = {}
if runtime_opt == "coreclr":
- fw = "net6.0"
- runtime_params["runtime_config"] = str(
- bin_path / "Python.Test.runtimeconfig.json"
- )
+ # This is optional now:
+ #
+ # fw = "net6.0"
+ # runtime_params["runtime_config"] = str(
+ # bin_path / "Python.Test.runtimeconfig.json"
+ # )
collect_ignore.append("domain_tests/test_domain_reload.py")
else:
domain_tests_dir = cwd / "domain_tests"
diff --git a/tests/test_conversion.py b/tests/test_conversion.py
index a5b4c6fd9..bb686dd52 100644
--- a/tests/test_conversion.py
+++ b/tests/test_conversion.py
@@ -577,6 +577,13 @@ class Foo(object):
ob.ObjectField = Foo
assert ob.ObjectField == Foo
+ class PseudoSeq:
+ def __getitem__(self, idx):
+ return 0
+
+ ob.ObjectField = PseudoSeq()
+ assert ob.ObjectField.__class__.__name__ == "PseudoSeq"
+
def test_null_conversion():
"""Test null conversion."""
@@ -713,3 +720,35 @@ def test_intptr_construction():
with pytest.raises(OverflowError):
UIntPtr(v)
+def test_explicit_conversion():
+ from operator import index
+ from System import (
+ Int64, UInt64, Int32, UInt32, Int16, UInt16, Byte, SByte, Boolean
+ )
+ from System import Double, Single
+
+ assert int(Boolean(False)) == 0
+ assert int(Boolean(True)) == 1
+
+ for t in [UInt64, UInt32, UInt16, Byte]:
+ assert index(t(127)) == 127
+ assert int(t(127)) == 127
+ assert float(t(127)) == 127.0
+
+ for t in [Int64, Int32, Int16, SByte]:
+ assert index(t(127)) == 127
+ assert index(t(-127)) == -127
+ assert int(t(127)) == 127
+ assert int(t(-127)) == -127
+ assert float(t(127)) == 127.0
+ assert float(t(-127)) == -127.0
+
+ assert int(Int64(Int64.MaxValue)) == 2**63 - 1
+ assert int(Int64(Int64.MinValue)) == -2**63
+ assert int(UInt64(UInt64.MaxValue)) == 2**64 - 1
+
+ for t in [Single, Double]:
+ assert float(t(0.125)) == 0.125
+ assert int(t(123.4)) == 123
+ with pytest.raises(TypeError):
+ index(t(123.4))
diff --git a/tests/test_module.py b/tests/test_module.py
index 4e1a1a1ef..ddfa7bb36 100644
--- a/tests/test_module.py
+++ b/tests/test_module.py
@@ -31,6 +31,7 @@ def test_import_clr():
def test_version_clr():
import clr
assert clr.__version__ >= "3.0.0"
+ assert clr.__version__[-1] != "\n"
def test_preload_var():
diff --git a/version.txt b/version.txt
index dc72b3783..916e2438f 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-3.0.0-rc4
+3.0.0-rc5
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