Hello, as was discussed in the bi-weekly meeting, the newest version seems to introduce stricter type checking. Here's a snippet that exhibits two issues. using (Py.GIL()) { dynamic sysmod = Py.Import("sys"); dynamic syspath = sysmod.path; bool found = false; foreach (var path in syspath) { if (path == Path.GetFullPath("some/test/path/").Replace("\\", "/")) { found = true; break; } } } The first is a runtime exception with syspath: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException : Cannot implicitly convert type 'Python.Runtime.PyObject' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?) The second is maybe a non-issue, but I think it used to work. If syspath is made to be of type PyList there is now a compiler error: error CS0019: Operator '==' cannot be applied to operands of type 'PyObject' and 'string' Thanks
I had not, it is indeed the same issue. On Thu, Feb 3, 2022 at 3:56 PM LOST _ <lostfreeman@gmail.com> wrote:
Exactly the same issue is reported here: https://github.com/pythonnet/pythonnet/issues/1680
Have you seen it?
*From: *Felix Bourbonnais <felix.bourbonnais@imaginary-spaces.com> *Sent: *Thursday, February 3, 2022 12:53 PM *To: *pythonnet@python.org *Subject: *[Python.NET] Stricter types in 3.0
Hello, as was discussed in the bi-weekly meeting, the newest version seems to introduce stricter type checking. Here's a snippet that exhibits two issues.
using (Py.GIL()) { dynamic sysmod = Py.Import("sys"); dynamic syspath = sysmod.path; bool found = false; foreach (var path in syspath) { if (path == Path.GetFullPath("some/test/path/").Replace("\\", "/")) { found = true; break; } } }
The first is a runtime exception with syspath: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException : Cannot implicitly convert type 'Python.Runtime.PyObject' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?)
The second is maybe a non-issue, but I think it used to work. If syspath is made to be of type PyList there is now a compiler error: error CS0019: Operator '==' cannot be applied to operands of type 'PyObject' and 'string'
Thanks
_______________________________________________ PythonNet mailing list -- pythonnet@python.org To unsubscribe send an email to pythonnet-leave@python.org https://mail.python.org/mailman3/lists/pythonnet.python.org/ Member address: felix.bourbonnais@imaginary-spaces.com
participants (2)
-
Felix Bourbonnais
-
LOST _