<div dir="ltr"><div><div><div><div><div><div><div>Hi,<br><br></div>I'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 "obvious" 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('default')<br><br>@when(f, 'x == 3')<br>def f(x):<br> print("I'm an integer")<br><br>f('test')<br>f(3)<br><br><br>Traceback (most recent call last):<br>
File "peak-rules_test_ko.py", line 6, in <module><br> @when(f, 'x == 3')<br> File "/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/DecoratorTools-1.8/peak/util/decorators.py", line 644, in do_decorate<br>
frame, getattr(f,'__name__',None), f, frame.f_locals<br> File "/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py", line 278, in callback<br>
register_for_class(None)<br> File "/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py", line 272, in register_for_class<br> _register_rule(f, pred, context, cls)<br>
File "/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py", line 398, in _register_rule<br> rules.add(parse_rule(Dispatching(gf).engine, pred, context, cls))<br>
File "/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py", line 689, in parse_rule<br> def parse_rule(engine, predicate, context, cls):<br> File "/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py", line 592, in callback<br>
return f(*args, **kw)<br> File "/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/core.py", line 952, in parse_upgrade<br> from peak.rules.predicates import IndexedEngine<br>
File "/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/predicates.py", line 4, in <module><br> from .criteria import *<br> File "/Users/herve/Documents/workspace/nagare/python3-ports/peak-py3/PEAK-Rules-0.5a1.dev-r2713/peak/rules/criteria.py", line 145, in <module><br>
inequalities = {<br>TypeError: nonempty __slots__ not supported for subtype of 'int'<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'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>