The following block of source code causes an exception
when tried to parse, listify and restoring an ast
object:
source = """
try:
try:
TRY_BLOCK
except EXC1:
EXC_BLOCK1
except EXC2:
EXC_BLOCK1
except EXC3:
FIN_BLOCK
"""
import parser
stlist = parser.suite(source).tolist() # o.k.
parser.sequence2st(stlist)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
ParserError: Expected node type 297, got -31392.
The node value -31392 is at random and not
reproducable.
The problem does not occur when only one except branch
in the inner try is used:
source = """
try:
try:
TRY_BLOCK
except EXC1:
EXC_BLOCK1
except EXC3:
FIN_BLOCK
"""
import parser
stlist = parser.suite(source).tolist() # o.k.
parser.sequence2st(stlist) # o.k.
It also doesn't occur for an outer finally-clause
instead of an except clause.
The problem is reproducable for Python 2.5
|