Title: NameError: global name 'parser' is not defined
Type: crash Severity: normal
Components: Library Versions:
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Lawouach, pjenvey
Priority: Keywords:

Created on 2009-07-31.07:26:37 by Lawouach, last changed 2009-08-04.08:49:07 by Lawouach.

msg4970 (view) Author: Sylvain Hellegouarch (Lawouach) Date: 2009-07-31.07:26:36
I'm getting the following exception (pasting the interesting bit here)
with r6591

File "/home/sylvain/dev/repos/jython/dist/Lib/compiler/",
line 53, in parse
    return Transformer().parsesuite(buf)
"/home/sylvain/dev/repos/jython/dist/Lib/compiler/", line
130, in parsesuite
    return self.transform(parser.suite(text))
NameError: global name 'parser' is not defined
msg4971 (view) Author: Philip Jenvey (pjenvey) Date: 2009-07-31.08:02:44
Hi Lawouach, we don't fully support the compiler module and never will. 
Though I'm curious, what library are you using that needs it? What's it 
calling the compiler module?

From my explanation in issue #1161, about the compiler module:

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

So migrating away from the compiler module will benefit libraries on 
Jython 2.5 as well as Python 3 going forward
msg4983 (view) Author: Sylvain Hellegouarch (Lawouach) Date: 2009-08-04.08:12:42
Hi Philip,

This comes from CherryPy using a module that evaluates config values
into Python values.

That being said, the workaround I'm using for now, is that when running
into an exception at that point, I'm doing a:

value = eval(value)

Which seems to work as far as I can tell so it's not blocking me per se.

I guess Jython should at least issue a warning statement about not
supporting the parser.
msg4984 (view) Author: Sylvain Hellegouarch (Lawouach) Date: 2009-08-04.08:49:07
Note however that the eval() trick doesn't workk all the time as it
cannot reproduce some aspects of the unrepr() function.
Date User Action Args
2009-08-04 08:49:07Lawouachsetmessages: + msg4984
2009-08-04 08:12:43Lawouachsetmessages: + msg4983
2009-07-31 08:02:45pjenveysetstatus: open -> closed
resolution: wont fix
messages: + msg4971
nosy: + pjenvey
2009-07-31 07:26:37Lawouachcreate