[Python.NET] Re: Stricter types in 3.0

Felix Bourbonnais <felix.bourbonnais-I5kDqsOpojRSLAGY5zujZ1aTQe2KTcn/@public.gmane.org> Thu, 3 Feb 2022 16:11:04 -0500
Newsgroups gmane.comp.python.dotnet
Message-ID <CAHfO0LsGrrnOA_qgiM8242PPxUKg61oU0k94kgkSjesAyVTv1g@mail.gmail.com>
--===============0310428010129398237==
Content-Type: multipart/alternative; boundary="0000000000000e5e4905d72393ea"

--0000000000000e5e4905d72393ea
Content-Type: text/plain; charset="UTF-8"

I had not, it is indeed the same issue.

On Thu, Feb 3, 2022 at 3:56 PM LOST _ <[email protected]> wrote:

> Exactly the same issue is reported here:
> https://github.com/pythonnet/pythonnet/issues/1680
>
>
>
> Have you seen it?
>
>
>
> *From: *Felix Bourbonnais <felix.bourbonnais-I5kDqsOpojRSLAGY5zujZ1aTQe2KTcn/@public.gmane.org>
> *Sent: *Thursday, February 3, 2022 12:53 PM
> *To: *[email protected]
> *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 -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/pythonnet.python.org/
> Member address: felix.bourbonnais-I5kDqsOpojRSLAGY5zujZ1aTQe2KTcn/@public.gmane.org
>

--0000000000000e5e4905d72393ea
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I had not, it is indeed the same issue.<br></div><br><div =
class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Thu, Feb 3, =
2022 at 3:56 PM LOST _ &lt;<a href=3D"mailto:[email protected]">lostfre=
[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padd=
ing-left:1ex"><div style=3D"overflow-wrap: break-word;" lang=3D"EN-US"><div=
 class=3D"gmail-m_-5801002538511680599WordSection1"><p class=3D"MsoNormal">=
Exactly the same issue is reported here: <a href=3D"https://github.com/pyth=
onnet/pythonnet/issues/1680" target=3D"_blank">https://github.com/pythonnet=
/pythonnet/issues/1680</a></p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></=
p><p class=3D"MsoNormal">Have you seen it?<u></u><u></u></p><p class=3D"Mso=
Normal"><u></u>=C2=A0<u></u></p><div style=3D"border-color:rgb(225,225,225)=
 currentcolor currentcolor;border-style:solid none none;border-width:1pt me=
dium medium;padding:3pt 0in 0in"><p class=3D"MsoNormal" style=3D"border:med=
ium none;padding:0in"><b>From: </b><a href=3D"mailto:felix.bourbonnais@imag=
inary-spaces.com" target=3D"_blank">Felix Bourbonnais</a><br><b>Sent: </b>T=
hursday, February 3, 2022 12:53 PM<br><b>To: </b><a href=3D"mailto:pythonne=
[email protected]" target=3D"_blank">[email protected]</a><br><b>Subject: </b=
>[Python.NET] Stricter types in 3.0</p></div><p class=3D"MsoNormal"><u></u>=
=C2=A0<u></u></p><div><div><p class=3D"MsoNormal">Hello, as was discussed i=
n the bi-weekly meeting, the newest version seems to introduce stricter typ=
e checking. Here&#39;s a snippet that exhibits two issues.</p></div><div><p=
 class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div><p class=3D"MsoNorm=
al">using (Py.GIL())<br>{<br>=C2=A0 =C2=A0 dynamic sysmod =3D Py.Import(&qu=
ot;sys&quot;);<br>=C2=A0 =C2=A0 dynamic syspath =3D sysmod.path;<br>=C2=A0 =
=C2=A0 bool found =3D false;<br>=C2=A0 =C2=A0 foreach (var path in syspath)=
<br>=C2=A0 =C2=A0 {<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (path =3D=3D Path.Get=
FullPath(&quot;some/test/path/&quot;).Replace(&quot;\\&quot;, &quot;/&quot;=
))<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 {<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 found =3D true;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;<=
br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br>=C2=A0 =C2=A0 }<br>}</p></div><div><p c=
lass=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div><p class=3D"MsoNormal=
">The first is a runtime exception with syspath: Microsoft.CSharp.RuntimeBi=
nder.RuntimeBinderException : Cannot implicitly convert type &#39;Python.Ru=
ntime.PyObject&#39; to &#39;System.Collections.IEnumerable&#39;. An explici=
t conversion exists (are you missing a cast?)</p></div><div><p class=3D"Mso=
Normal">The second is maybe a non-issue, but I think it used to work. If sy=
spath is made to be of type PyList there is now a compiler error: error CS0=
019: Operator &#39;=3D=3D&#39; cannot be applied to operands of type &#39;P=
yObject&#39; and &#39;string&#39;</p></div><div><p class=3D"MsoNormal"><u><=
/u>=C2=A0<u></u></p></div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u><=
/p></div></div><p class=3D"MsoNormal">Thanks</p><p class=3D"MsoNormal"><u><=
/u>=C2=A0<u></u></p></div></div>
_______________________________________________<br>
PythonNet mailing list -- <a href=3D"mailto:[email protected]" target=3D=
"_blank">[email protected]</a><br>
To unsubscribe send an email to <a href=3D"mailto:[email protected]=
g" target=3D"_blank">[email protected]</a><br>
<a href=3D"https://mail.python.org/mailman3/lists/pythonnet.python.org/" re=
l=3D"noreferrer" target=3D"_blank">https://mail.python.org/mailman3/lists/p=
ythonnet.python.org/</a><br>
Member address: <a href=3D"mailto:felix.bourbonnais-I5kDqsOpojRSLAGY5zujZ1aTQe2KTcn/@public.gmane.org" t=
arget=3D"_blank">felix.bourbonnais-I5kDqsOpojRSLAGY5zujZ1aTQe2KTcn/@public.gmane.org</a><br>
</blockquote></div>

--0000000000000e5e4905d72393ea--

--===============0310428010129398237==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
PythonNet mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/pythonnet.python.org/
Member address: [email protected]

--===============0310428010129398237==--