You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
lengthToLen() is called when the selection pattern doesn't fully match #21
So part of tracking down the length issue (since I'm seeing that currently), I noticed that the
call transforms.lengthToLen() got called repeatedly for transforms that weren't related to the selection definition for that
function.
Breaking in with the python debugger gave me the following:
Further tracing shows the problem to be in the Selector.gt() function in lang/selector.py:
def __gt__(self, other):
""" E > F
Like CSS: "E > F": an F element child of an E element
"""
return Child(self, other)
In the case of Type(A) > Type(B) > Type(C), the interpreter is evaluating Type(A) > Type(B) as True first and then returns the
value of Type(B) > Type(C).
<class '__main__.A'>__gt__() called
<class '__main__.B'>__gt__() called
<class '__main__.C'>__gt__() called
Output: <class '__main__.C'>
<class '__main__.C'>__gt__() called
<class '__main__.B'>__gt__() called
<class '__main__.A'>__gt__() called
Output: <class '__main__.A'>
This the exact behavior I saw with the selector. In the first case, whatever A and B returns are tossed. Parens are added to force the correct behavior in the second case.
Activity
rcludwick commentedon May 21, 2012
I'm thinking that one option might be to override the >> op instead, but I'm trying to think if there's a left to right issue.
Ideally, for Type(A) >> Type(B) >> Type(C) I think I'd want:
But right now, I'd get:
Are those equivalent selections?
natural commentedon May 21, 2012
Thanks for the detailed analysis and ticket. That's truly appreciated.
I think the selector is wrong; the
Type('METHOD_CALL')doesn't need to be in there at all.I checked the
__gt__issue, and it works like I expect in a test case that's outside of j2py, so I'll revisit that when I'm wrapping this up.rcludwick commentedon May 21, 2012
Here's the source file I was concentrating on, and it could serve as a good test case for the conversion of length to len():
http://code.google.com/p/zxing/source/browse/trunk/core/src/com/google/zxing/common/reedsolomon/GenericGFPoly.java
When I ran j2py against that, j2py crashed.
The AST being passed into lengthToLen didn't resemble the AST lengthToLen is expecting in it's docstring.
This is the code I tested to test the gt()
The output looks like this:
This the exact behavior I saw with the selector. In the first case, whatever A and B returns are tossed. Parens are added to force the correct behavior in the second case.