You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the introduction of Span in .NET, more and more methods have arguments of ReadOnlySpan<char> as apposed to string and ReadOnlySpan<bytes> instead of a byte array. Calling methods that have an argument or return type of Span from python results in exceptions being raised. This is becoming a big limitation in IronPython.
.NET Version is 8.0 (also reproduces on earlier versions)
IronPython 3.4.1 (latest)
I found this issue talking about the boxing issue with Span, however, I think the cases in which string or a byte array can be converted automatically to Span should be handled. This would solve the issue for most methods, and hopefully get around the boxing issue for these basic cases.
Steps to Reproduce
Run the following python code from IronPython:
importclrclr.AddReference("System.Security.Cryptography.Algorithms")
fromSystem.Security.CryptographyimportRSAkey_pem="""-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzwTp4JKBcB4Xo8XMvwvW9t1skgssLMv0dflO3Es4Q2iItyeAbuwtV8D/LCaD6L9MKV/3qzAr5lXmld9rh9Z0XbABS6476TEeMFlbGxHSzil87tQIUTRDyIcXGdvMiKtkkbq5lpMPLnZSsnLk0j/sJih8xHM3KpGm6K4s+yWH8plp3div5R4oNIJsNriR1YJmyqwaS4IYmbK/mS5fBO616ZedwdN5A5LWUXJqjoY0Z0weRIPgUbTQMKAaEyChyuKO4mfu6em+oD4PJnVwNsjfShIMtO5KmHXn0PZPLLf+PwEdQKNwYGF8ZJLoLRH781Zj8vbc53yA54OhpSallJyCGQIDAQAB-----END PUBLIC KEY-----"""rsa=RSA.Create()
rsa.ImportFromPem(key_pem)
Expected behavior:
Code runs without exceptions.
Actual behavior:
Exception calling rsa.ImportFromPem with a signature of public override void ImportFromPem (ReadOnlySpan<char> input);:
ArgumentException with InnerException of TypeLoadException:
GenericArguments[3], 'System.ReadOnlySpan`1[System.Char]', on 'Microsoft.Scripting.Interpreter.FuncCallInstruction`4[T0,T1,T2,TRet]' violates the constraint of type parameter 'TRet'.
TypeLoadException stack trace:
at System.RuntimeTypeHandle.Instantiate(QCallTypeHandle handle, IntPtr* pInst, Int32 numGenericArgs, ObjectHandleOnStack type)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
ArgumentException stack trace:
at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
at Microsoft.Scripting.Interpreter.CallInstruction.GetHelperType(MethodInfo info, Type[] arrTypes)
at Microsoft.Scripting.Interpreter.CallInstruction.SlowCreate(MethodInfo info, ParameterInfo[] pis)
at Microsoft.Scripting.Interpreter.CallInstruction.Create(MethodInfo info, ParameterInfo[] parameters)
at Microsoft.Scripting.Interpreter.DynamicInstructionN..ctor(Type delegateType, CallSite site)
at Microsoft.Scripting.Interpreter.InstructionList.CreateDynamicInstruction(Type delegateType, CallSiteBinder binder)
at Microsoft.Scripting.Interpreter.LightCompiler.CompileDynamicExpression(Expression expr)
at Microsoft.Scripting.Interpreter.LightCompiler.CompileMethodCallExpression(Expression expr)
at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid(Expression expr)
at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockStart(BlockExpression node)
at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression(Expression expr, Boolean
[[SNIP]]
Version Information
Windows 10
.NET Version is 8.0 (also reproduces on earlier versions)
IronPython 3.4.1 (latest)
The text was updated successfully, but these errors were encountered:
Description
With the introduction of Span in .NET, more and more methods have arguments of
ReadOnlySpan<char>
as apposed tostring
andReadOnlySpan<bytes>
instead of a byte array. Calling methods that have an argument or return type of Span from python results in exceptions being raised. This is becoming a big limitation in IronPython..NET Version is 8.0 (also reproduces on earlier versions)
IronPython 3.4.1 (latest)
I found this issue talking about the boxing issue with
Span
, however, I think the cases in which string or a byte array can be converted automatically to Span should be handled. This would solve the issue for most methods, and hopefully get around the boxing issue for these basic cases.Steps to Reproduce
Run the following python code from IronPython:
Expected behavior:
Code runs without exceptions.
Actual behavior:
Exception calling
rsa.ImportFromPem
with a signature ofpublic override void ImportFromPem (ReadOnlySpan<char> input);
:ArgumentException
with InnerException ofTypeLoadException
:TypeLoadException
stack trace:ArgumentException
stack trace:Version Information
Windows 10
.NET Version is 8.0 (also reproduces on earlier versions)
IronPython 3.4.1 (latest)
The text was updated successfully, but these errors were encountered: