On 28/02/12 13:25, Lex Trotman wrote:
[...]
I poked around and *suspect* that the error was introduced with this
changeset:

http://code.google.com/p/asciidoc/source/detail?r=66543730504e5dc07a56fcd89b238ef784cdeac4

which uses the Python compiler to remove eval()s.

I would like AsciiDoc to work with Jython so if anyone can figure out
exactly what's causing it and come up with at patch that would be great.


Hi Stuart,

Perhaps one solution would be to use the parser module instead of the
compiler module, this is messier and harder to use since you have to
refer to the detailed grammar, but is available for all Python 2
versions.  I don't think the grammar for "safe" literal structures (ie
expr) has changed across Python versions so the result should be
portable.

literal_eval() would need to be re-written to use the output of the
parser module, but that should be fairly mechanical.

Thanks Lex, a bit more digging and it turns out to be the Jython compiler.parse() function in parse_to_list() e.g.

>>> compiler.parse("[" + '"==","--","~~","^^","++"' + "]", mode='eval')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
File "/home/srackham/local/bin/jython2.5.2/Lib/compiler/transformer.py", line 55, in parse
    return Transformer().parseexpr(buf)
File "/home/srackham/local/bin/jython2.5.2/Lib/compiler/transformer.py", line 134, in parseexpr
    return self.transform(parser.expr(text))
NameError: global name 'parser' is not defined
>>>

A similar issue reported here http://bugs.jython.org/issue1417 comes with the comment:

``Jython doesn't fully support it and never will, because a) it generates
.pyc bytecode that we don't use b) it heavily relies on the parser
module which we will never support either c) is pending deprecation and
was removed in Python 3

The parser module provides the low level innards of CPython's parser
(which is really nothing like ours), and the way to deal with AST going
forward is via the _ast module, which we support and was originally
added in CPython 2.5. We also support the ast (no underscore) module, as
well as the ability to pass modified/generated AST to the compile
function, which were both added in CPython 2.6''

The implication being that the parser module will suffer the same problems.

As far as I'm concerned the cure is worse than the disease and we should just roll back http://code.google.com/p/asciidoc/source/detail?r=66543730504e5dc07a56fcd89b238ef784cdeac4


Cheers, Stuart



Cheers
Lex


Cheers, Stuart



Thanks.


--
You received this message because you are subscribed to the Google Groups
"asciidoc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/asciidoc?hl=en.



--
You received this message because you are subscribed to the Google Groups 
"asciidoc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/asciidoc?hl=en.

Reply via email to