[PEAK] trying to run peak-rules on python3

Hervé Coatanhay herve.coatanhay at gmail.com
Mon Mar 18 13:56:18 EDT 2013


Hi,

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.

Here is how I proceeded:
1) run 2to3 on these packages
2) fix remaining "obvious" issue (no more `file` builtin, package renaming,
...)
3) fix types/new/ast changes made in python3
4) remove rules on old-style classes

Here is the code produced by this very naive approach
https://bitbucket.org/Alzakath/peak-py3.

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:

from peak.rules import when

def f(x):
    print('default')

@when(f, 'x == 3')
def f(x):
    print("I'm an integer")

f('test')
f(3)


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

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 ?

Cheers,
Herve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eby-sarna.com/pipermail/peak/attachments/20130318/c215de4d/attachment.html


More information about the PEAK mailing list