
try:
    print("try 1")
    try:
        print("try 2")
        foo()
    except:
        print("except 2")
    bar()
except:
    print("except 1")

try:
    print("try 1")
    try:
        print("try 2")
        foo()
    except TypeError:
        print("except 2")
    bar()
except NameError:
    print("except 1")


try:
    print("try 1")
    try:
        print("try 2")
        foo()
    except:
        print("except 2")
    bar()
except:
    print("except 1")

try:
    print("try 1")
    try:
        print("try 2")
        foo()
    except TypeError:
        print("except 2")
    bar()
except NameError:
    print("except 1")

# Check that exceptions across function boundaries work as expected
def func1():
    try:
        print("try func1")
        func2()
    except NameError:
        print("except func1")

def func2():
    try:
        print("try func2")
        foo()
    except TypeError:
        print("except func2")

func1()

Add testcase with exception handler spread across functions.
Add testcase with exception handler spread across functions.

  
  try:
      print("try 1")
      try:
          print("try 2")
          foo()
      except:
          print("except 2")
      bar()
  except:
      print("except 1")
  
  try:
      print("try 1")
      try:
          print("try 2")
          foo()
      except TypeError:
          print("except 2")
      bar()
  except NameError:
      print("except 1")
  
+ # Check that exceptions across function boundaries work as expected
+ def func1():
+     try:
+         print("try func1")
+         func2()
+     except NameError:
+         print("except func1")
+ 
+ def func2():
+     try:
+         print("try func2")
+         foo()
+     except TypeError:
+         print("except func2")
+ 
+ func1()
+ 
Add testcase with exception handler spread across functions.
## Code Before:

try:
    print("try 1")
    try:
        print("try 2")
        foo()
    except:
        print("except 2")
    bar()
except:
    print("except 1")

try:
    print("try 1")
    try:
        print("try 2")
        foo()
    except TypeError:
        print("except 2")
    bar()
except NameError:
    print("except 1")

## Instruction:
Add testcase with exception handler spread across functions.
## Code After:

try:
    print("try 1")
    try:
        print("try 2")
        foo()
    except:
        print("except 2")
    bar()
except:
    print("except 1")

try:
    print("try 1")
    try:
        print("try 2")
        foo()
    except TypeError:
        print("except 2")
    bar()
except NameError:
    print("except 1")

# Check that exceptions across function boundaries work as expected
def func1():
    try:
        print("try func1")
        func2()
    except NameError:
        print("except func1")

def func2():
    try:
        print("try func2")
        foo()
    except TypeError:
        print("except func2")

func1()
