Re: PEAK-Rules and PyPy
Alain Poirier <alain.poirier-HPmRmcG/[email protected]> Tue, 16 Oct 2012 18:48:07 +0200
| Newsgroups | gmane.comp.python.peak |
|---|---|
| Message-ID | <[email protected]> |
Le 16 oct. 2012 =E0 18:26, Marcin Tustin <[email protected]> a = =E9crit : > Please see: = http://docs.python.org/library/__builtin__.html?highlight=3D__builtins__ Thanks Marcin. I see from the 'CPython implementation detail' note, = '__builtins__' can be a module or a dict. Ok, so I added a check to use = '__builtins__.__dict__' if '__builtins__' is a module and now I've got: >>>> from peak.rules import predicates Traceback (most recent call last): File "<console>", line 1, in <module> File = "/private/tmp/p/site-packages/DecoratorTools-1.8-py2.7.egg/peak/util/decor= ators.py", line 617, in tracer frm.f_locals[k] =3D callback(frm,k,v,old_locals) File "/private/tmp/PEAK-Rules-0.5a1.dev-r2707/peak/rules/core.py", = line 276, in callback register_for_class(None) File "/private/tmp/PEAK-Rules-0.5a1.dev-r2707/peak/rules/core.py", = line 270, in register_for_class _register_rule(f, pred, context, cls) File "/private/tmp/PEAK-Rules-0.5a1.dev-r2707/peak/rules/core.py", = line 395, in _register_rule rules.add(parse_rule(Dispatching(gf).engine, pred, context, cls)) File "/private/tmp/PEAK-Rules-0.5a1.dev-r2707/peak/rules/core.py", = line 685, in parse_rule def parse_rule(engine, predicate, context, cls): File "/private/tmp/PEAK-Rules-0.5a1.dev-r2707/peak/rules/core.py", = line 953, in parse_upgrade predicate, context, cls File "/private/tmp/PEAK-Rules-0.5a1.dev-r2707/peak/rules/core.py", = line 685, in parse_rule def parse_rule(engine, predicate, context, cls): File = "/private/tmp/PEAK-Rules-0.5a1.dev-r2707/peak/rules/predicates.py", line = 606, in _parse_string maybe_bind(ctx.body, bindings), expr, ctx.actiontype, ctx.sequence UnboundLocalError: local variable 'expr' referenced before assignment which is strange because 'expr' is just defined some lines above. > CPython implementation detail: Most modules have the name __builtins__ = (note the 's') made available as part of their globals. The value = of__builtins__ is normally either this module or the value of this = modules=92s __dict__ attribute. Since this is an implementation detail, = it may not be used by alternate implementations of Python. >=20 > On Tue, Oct 16, 2012 at 12:22 PM, PJ Eby <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]> = wrote: > On Tue, Oct 16, 2012 at 11:18 AM, Alain Poirier > <alain.poirier-HPmRmcG/[email protected]> wrote: > > File = "/private/tmp/PEAK-Rules-0.5a1.dev-r2707/peak/rules/predicates.py", line = 595, in _parse_string > > b =3D CriteriaBuilder(engine.arguments, ctx.localdict, = ctx.globaldict, __builtins__) > > File = "/private/tmp/PEAK-Rules-0.5a1.dev-r2707/peak/rules/codegen.py", line = 334, in __init__ > > dict([(k,self.Const(v)) for k,v in ns.iteritems()]) for ns in = namespaces > > AttributeError: 'module' object has no attribute 'iteritems' > > > > > > Do you think it could be possible to have a working PyPy version of = Peak Rules? >=20 > It depends. It looks like the problem above is that __builtins__ in > PyPy might be a module instead of a dictionary? If so, that's > probably a bug in PyPy that needs to be fixed. >=20 > There are likely to be other problems besides this one, but let's take > them one at a time. ;-)