This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: parser module bug for nested try...except statements
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, schluehrk
Priority: normal Keywords:

Created on 2006-11-13 13:00 by schluehrk, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg30532 - (view) Author: Kay Schluehr (schluehrk) Date: 2006-11-13 13:00
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

msg30533 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-11-13 13:26
Logged In: YES 
user_id=849994

I can reproduce this with the 2.5.0 release, but not with
the latest 2.5 SVN or the 2.6 SVN.
Closing as outdated.
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44228
2006-11-13 13:00:29schluehrkcreate