<div dir="ltr"><div><div><div><div><div><div><div>Hi,<br><br></div>I&#39;m trying to port nagare to python3. I managed to run a simple application but I had to make some changes in few PEAK packages.<br><br></div>Here is how I proceeded:<br>

</div>1) run 2to3 on these packages<br></div>2) fix remaining &quot;obvious&quot; issue (no more `file` builtin, package renaming, ...)<br></div>3) fix types/new/ast changes made in python3<br></div><div>4) remove rules on old-style classes<br>

</div><div><br></div>Here is the code produced by this very naive approach <a href="https://bitbucket.org/Alzakath/peak-py3" target="_blank">https://bitbucket.org/Alzakath/peak-py3</a>.<br><br></div>As a result, PEAK-Rules seems to work when I only use dispatch on type. But it seems predicate dispatch is not working, for example:<br>

<br>from peak.rules import when<br><br>def f(x):<br>    print(&#39;default&#39;)<br><br>@when(f, &#39;x == 3&#39;)<br>def f(x):<br>    print(&quot;I&#39;m an integer&quot;)<br><br>f(&#39;test&#39;)<br>f(3)<br><br><br>Traceback (most recent call last):<br>

  File &quot;peak-rules_test_ko.py&quot;, line 6, in &lt;module&gt;<br>    @when(f, &#39;x == 3&#39;)<br>  File &quot;/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/DecoratorTools-1.8/peak/util/decorators.py&quot;, line 644, in do_decorate<br>

    frame, getattr(f,&#39;__name__&#39;,None), f, frame.f_locals<br>  File &quot;/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py&quot;, line 278, in callback<br>

    register_for_class(None)<br>  File &quot;/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py&quot;, line 272, in register_for_class<br>    _register_rule(f, pred, context, cls)<br>

  File &quot;/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py&quot;, line 398, in _register_rule<br>    rules.add(parse_rule(Dispatching(gf).engine, pred, context, cls))<br>

  File &quot;/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py&quot;, line 689, in parse_rule<br>    def parse_rule(engine, predicate, context, cls):<br>  File &quot;/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py&quot;, line 592, in callback<br>

    return f(*args, **kw)<br>  File &quot;/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py&quot;, line 952, in parse_upgrade<br>    from peak.rules.predicates import IndexedEngine<br>

  File &quot;/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/predicates.py&quot;, line 4, in &lt;module&gt;<br>    from .criteria import *<br>  File &quot;/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/criteria.py&quot;, line 145, in &lt;module&gt;<br>

    inequalities = {<br>TypeError: nonempty __slots__ not supported for subtype of &#39;int&#39;<br><br><div>Does anyone tried to port peak-rules to python3 ? Do you have any advice on the right way to do it ? Or even hints on what I&#39;m missing ? <br>
</div><div><div><div><div><div><div><div><div><br></div><div>Cheers,<br></div><div>Herve<br></div></div></div></div></div></div></div></div></div>