Re: trying to run peak-rules on python3

HervĂ© Coatanhay <[email protected]> Tue, 19 Mar 2013 11:57:26 -0700
Newsgroups gmane.comp.python.peak
Message-ID <CAPq7H1ZyRREwp3HKfuH3oDPzeV8h_GnjVYiy7KgM9e-VcqNZVA@mail.gmail.com>
--===============0495427463==
Content-Type: multipart/alternative; boundary=047d7bdc9fd231598004d84bade1

--047d7bdc9fd231598004d84bade1
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

So from what I'm understanding BytesCodeAssembler is not in a too bad shape
atm regarding py3 if i just want to run PEAK-Rules (i still have to look
into the problem with `from_function`).

The way i run the test is:
nosetests --with-doctest --doctest-extension=3Dtxt
--doctest-options=3D'+ELLIPSIS,+NORMALIZE_WHITESPACE'

so whitespaces differences should be ignored properly

>     >>> from peak.util.assembler import TryExcept
>     >>> c =3D Code()
>     >>> c.return_(
>     ...     TryExcept(
>     ...         Return(1),                                      # body
>     ...         [(Const(KeyError),2), (Const(TypeError),3)],    # handler=
s
>     ...         Return(4)                                       # else
> clause
>     ...     )
>     ... )

It was a typo as i replace both exceptions.KeyError and
exceptions.TypeError with KeyError.

As of running PEAK-Rules tests, i have trouble running them because the
previous command does not find any. How do you run them actually ?

Herve


On Tue, Mar 19, 2013 at 10:25 AM, PJ Eby <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]> wrote:

> On Tue, Mar 19, 2013 at 11:04 AM, Herv=C3=A9 Coatanhay
> <[email protected]> wrote:
> > FYI
> >
> > I did changes in README.txt to pass test. Mostly obvious ones, like pri=
nt
> > and types changes. But i had to replace DUP_TOPX with DUP_TOP_TWO (I'm
> not
> > entirely sure if that's OK).
>
> Me either.  I haven't messed with py3 bytecode at all yet.  But if I
> understand correctly, DUP_TOPX(1) would map to DUP_TOP and DUP_TOPX(2)
> would map to DUP_TOP_TWO, but any larger number and it's more
> complicated than that.
>
>
> > There are still some failing tests. One seems like some discrepancy
> between
> > python2 and python3:
> >
> > In python2:
> >>>> exec(compile('42', '', 'eval'))
> >>>> eval(compile('42', '', 'eval'))
> > 42
> >
> > In python3:
> >>>> exec(compile('42', '', 'eval'))
> > 42
> >>>> eval(compile('42', '', 'eval'))
> > 42
>
> That one probably won't affect anything in PEAK-Rules.
>
>
> > Other failing tests a related to the use of from_function classmethod.
> I'm
> > suspecting some issue with DecoratorTools because Decoratools tests are
> not
> > passing. I'll try to make them pass.
> >
> > Finally, there are 2 tests failing that i don't know where to start wit=
h:
> >
> >     >>> from peak.util.assembler import TryExcept
> >     >>> c =3D Code()
> >     >>> c.return_(
> >     ...     TryExcept(
> >     ...         Return(1),                                      # body
> >     ...         [(Const(KeyError),2), (Const(TypeError),3)],    #
> handlers
> >     ...         Return(4)                                       # else
> > clause
> >     ...     )
> >     ... )
>
> Not sure what's up with this one: the log you sent shows this actually
> having the same code (or at least as far as I can see).  It shouldn't
> be a whitespace difference, as I think the flags are set to ignore
> those.
>
>
> >     >>> c =3D Code()
> >     >>> c(1, True, 1.0, 1)     # equal, but different types
> >     >>> dis(c.code())
>
> This is a 2to3 artifact: the original test had the fourth value as
> "1L", which resulted in a fourth constant.  Python 3 doesn't have a
> distinct type for longs, so there's no way to create that value.  So
> this failure is of no consequence.
>
> Anyway, what about PEAK-Rules' own tests?  It's got quite a lot of
> them, including for the criteria and predicate and indexing systems.
>



--=20
dyslectics have more fnu

--047d7bdc9fd231598004d84bade1
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">So from what I&#39;m understanding BytesCodeAssembler is n=
ot in a too bad shape atm regarding py3 if i just want to run PEAK-Rules (i=
 still have to look into the problem with `<span style=3D"color:rgb(80,0,80=
);font-family:arial,sans-serif;font-size:13px">from_function`).</span><div>
<span style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13=
px"><br></span></div><div style><span style=3D"color:rgb(80,0,80);font-fami=
ly:arial,sans-serif;font-size:13px">The way i run the test is:</span></div>
<div style><font color=3D"#500050" face=3D"arial, sans-serif">nosetests --w=
ith-doctest --doctest-extension=3Dtxt --doctest-options=3D&#39;+ELLIPSIS,+N=
ORMALIZE_WHITESPACE&#39;</font><br></div><div style><font color=3D"#500050"=
 face=3D"arial, sans-serif"><br>
</font></div><div style><font color=3D"#500050" face=3D"arial, sans-serif">=
so whitespaces differences should be ignored properly</font></div><div styl=
e><font color=3D"#500050" face=3D"arial, sans-serif"><br></font></div><div =
style>
<span style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13=
px">&gt; =C2=A0 =C2=A0 &gt;&gt;&gt; from peak.util.assembler import TryExce=
pt</span><br style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-=
size:13px">
<span style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13=
px">&gt; =C2=A0 =C2=A0 &gt;&gt;&gt; c =3D Code()</span><br style=3D"color:r=
gb(80,0,80);font-family:arial,sans-serif;font-size:13px"><span style=3D"col=
or:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">&gt; =C2=A0 =
=C2=A0 &gt;&gt;&gt; c.return_(</span><br style=3D"color:rgb(80,0,80);font-f=
amily:arial,sans-serif;font-size:13px">
<span style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13=
px">&gt; =C2=A0 =C2=A0 ... =C2=A0 =C2=A0 TryExcept(</span><br style=3D"colo=
r:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"><span style=3D"=
color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">&gt; =C2=A0=
 =C2=A0 ... =C2=A0 =C2=A0 =C2=A0 =C2=A0 Return(1), =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# body</span><br style=3D"color:rgb(80,0,=
80);font-family:arial,sans-serif;font-size:13px">
<span style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13=
px">&gt; =C2=A0 =C2=A0 ... =C2=A0 =C2=A0 =C2=A0 =C2=A0 [(Const(KeyError),2)=
, (Const(TypeError),3)], =C2=A0 =C2=A0# handlers</span><br style=3D"color:r=
gb(80,0,80);font-family:arial,sans-serif;font-size:13px">
<span style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13=
px">&gt; =C2=A0 =C2=A0 ... =C2=A0 =C2=A0 =C2=A0 =C2=A0 Return(4) =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # else</span><br style=3D"=
color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">
<span style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13=
px">&gt; clause</span><br style=3D"color:rgb(80,0,80);font-family:arial,san=
s-serif;font-size:13px"><span style=3D"color:rgb(80,0,80);font-family:arial=
,sans-serif;font-size:13px">&gt; =C2=A0 =C2=A0 ... =C2=A0 =C2=A0 )</span><b=
r style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">
<span style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13=
px">&gt; =C2=A0 =C2=A0 ... )</span><br></div><div style><span style=3D"colo=
r:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"><br></span></di=
v><div style>
<font color=3D"#500050" face=3D"arial, sans-serif">It was a typo as i repla=
ce both exceptions.KeyError and exceptions.TypeError with KeyError.</font><=
/div><div style><font color=3D"#500050" face=3D"arial, sans-serif"><br></fo=
nt></div>
<div style><font color=3D"#500050" face=3D"arial, sans-serif">As of running=
 PEAK-Rules tests, i have trouble running them because the previous command=
 does not find any. How do you run them actually ?</font></div><div style><=
font color=3D"#500050" face=3D"arial, sans-serif"><br>
</font></div><div style><font color=3D"#500050" face=3D"arial, sans-serif">=
Herve</font></div></div><div class=3D"gmail_extra"><br><br><div class=3D"gm=
ail_quote">On Tue, Mar 19, 2013 at 10:25 AM, PJ Eby <span dir=3D"ltr">&lt;<=
a href=3D"mailto:pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]" target=3D"_blank">pje@telecommunity=
.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div class=3D"im">On Tue, Mar 19, 2013 at 11=
:04 AM, Herv=C3=A9 Coatanhay<br>
&lt;<a href=3D"mailto:[email protected]">[email protected]<=
/a>&gt; wrote:<br>
&gt; FYI<br>
&gt;<br>
&gt; I did changes in README.txt to pass test. Mostly obvious ones, like pr=
int<br>
&gt; and types changes. But i had to replace DUP_TOPX with DUP_TOP_TWO (I&#=
39;m not<br>
&gt; entirely sure if that&#39;s OK).<br>
<br>
</div>Me either. =C2=A0I haven&#39;t messed with py3 bytecode at all yet. =
=C2=A0But if I<br>
understand correctly, DUP_TOPX(1) would map to DUP_TOP and DUP_TOPX(2)<br>
would map to DUP_TOP_TWO, but any larger number and it&#39;s more<br>
complicated than that.<br>
<div class=3D"im"><br>
<br>
&gt; There are still some failing tests. One seems like some discrepancy be=
tween<br>
&gt; python2 and python3:<br>
&gt;<br>
&gt; In python2:<br>
&gt;&gt;&gt;&gt; exec(compile(&#39;42&#39;, &#39;&#39;, &#39;eval&#39;))<br=
>
&gt;&gt;&gt;&gt; eval(compile(&#39;42&#39;, &#39;&#39;, &#39;eval&#39;))<br=
>
&gt; 42<br>
&gt;<br>
&gt; In python3:<br>
&gt;&gt;&gt;&gt; exec(compile(&#39;42&#39;, &#39;&#39;, &#39;eval&#39;))<br=
>
&gt; 42<br>
&gt;&gt;&gt;&gt; eval(compile(&#39;42&#39;, &#39;&#39;, &#39;eval&#39;))<br=
>
&gt; 42<br>
<br>
</div>That one probably won&#39;t affect anything in PEAK-Rules.<br>
<div class=3D"im"><br>
<br>
&gt; Other failing tests a related to the use of from_function classmethod.=
 I&#39;m<br>
&gt; suspecting some issue with DecoratorTools because Decoratools tests ar=
e not<br>
&gt; passing. I&#39;ll try to make them pass.<br>
&gt;<br>
&gt; Finally, there are 2 tests failing that i don&#39;t know where to star=
t with:<br>
&gt;<br>
&gt; =C2=A0 =C2=A0 &gt;&gt;&gt; from peak.util.assembler import TryExcept<b=
r>
&gt; =C2=A0 =C2=A0 &gt;&gt;&gt; c =3D Code()<br>
&gt; =C2=A0 =C2=A0 &gt;&gt;&gt; c.return_(<br>
&gt; =C2=A0 =C2=A0 ... =C2=A0 =C2=A0 TryExcept(<br>
&gt; =C2=A0 =C2=A0 ... =C2=A0 =C2=A0 =C2=A0 =C2=A0 Return(1), =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# body<br>
&gt; =C2=A0 =C2=A0 ... =C2=A0 =C2=A0 =C2=A0 =C2=A0 [(Const(KeyError),2), (C=
onst(TypeError),3)], =C2=A0 =C2=A0# handlers<br>
&gt; =C2=A0 =C2=A0 ... =C2=A0 =C2=A0 =C2=A0 =C2=A0 Return(4) =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # else<br>
&gt; clause<br>
&gt; =C2=A0 =C2=A0 ... =C2=A0 =C2=A0 )<br>
&gt; =C2=A0 =C2=A0 ... )<br>
<br>
</div>Not sure what&#39;s up with this one: the log you sent shows this act=
ually<br>
having the same code (or at least as far as I can see). =C2=A0It shouldn&#3=
9;t<br>
be a whitespace difference, as I think the flags are set to ignore<br>
those.<br>
<div class=3D"im"><br>
<br>
&gt; =C2=A0 =C2=A0 &gt;&gt;&gt; c =3D Code()<br>
&gt; =C2=A0 =C2=A0 &gt;&gt;&gt; c(1, True, 1.0, 1) =C2=A0 =C2=A0 # equal, b=
ut different types<br>
&gt; =C2=A0 =C2=A0 &gt;&gt;&gt; dis(c.code())<br>
<br>
</div>This is a 2to3 artifact: the original test had the fourth value as<br=
>
&quot;1L&quot;, which resulted in a fourth constant. =C2=A0Python 3 doesn&#=
39;t have a<br>
distinct type for longs, so there&#39;s no way to create that value. =C2=A0=
So<br>
this failure is of no consequence.<br>
<br>
Anyway, what about PEAK-Rules&#39; own tests? =C2=A0It&#39;s got quite a lo=
t of<br>
them, including for the criteria and predicate and indexing systems.<br>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>dyslectics h=
ave more fnu
</div>

--047d7bdc9fd231598004d84bade1--

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

_______________________________________________
PEAK mailing list
[email protected]
http://www.eby-sarna.com/mailman/listinfo/peak
--===============0495427463==--