-
-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
While checking some code related to #190 I've discovered another bug.
Let me start with a demo:
from pathlib import Path
from redbaron import RedBaron
src = Path('demo.py').read_text()
fst = RedBaron(src)
fimp1, = fst.find_all('from_import')
fimp1.insert_after(fimp1)
Path('out.demo.py').write_text(fst.dumps())
demo.py
:
from x import y
def func(x, y, z):
try:
return
c()
except:
smth()
class A:
try:
return
c()
except:
smth()
try:
try:
return
c()
except:
smth()
except:
pass
try:
try:
try:
return
c()
except:
smth()
return
except:
pass
except:
pass
out.demo.py
:
from x import y
from x import y
def func(x, y, z):
try:
return
c()
except:
smth()
class A:
try:
return
c()
except:
smth()
try:
try:
return
c()
except:
smth()
except:
pass
try:
try:
try:
return
c()
except:
smth()
return
except:
pass
except:
pass
What's wrong?
If you look closer, you'll notice that some of the except:
lines don't have any indentation at all after dumping.
It looks like this only happens when the return
statement is present in the try
part and from ... import ...
statement is inserted into FST (top level?). Also, it doesn't seem to affect try/return/except on the third level of nesting.
N.B. Along with this issue, I also observe #190.
Metadata
Metadata
Assignees
Labels
No labels