@@ -1706,3 +1706,144 @@ def test_try_except_as_stmt_indent():
17061706],
17071707 }
17081708 ])
1709+
1710+ def test_try_excepts_stmt_empty_same_line ():
1711+ """
1712+ try: pass
1713+ except:
1714+ pass
1715+ """
1716+ parse_multi ([
1717+ ('TRY' , 'try' ),
1718+ ('COLON' , ':' ),
1719+ ('PASS' , 'pass' , [('SPACE' , ' ' )]),
1720+ ('ENDL' , '\n ' ),
1721+ ('EXCEPT' , 'except' ),
1722+ ('COLON' , ':' ),
1723+ ('ENDL' , '\n ' , [], [('SPACE' , ' ' )]),
1724+ ('INDENT' , '' ),
1725+ ('PASS' , 'pass' ),
1726+ ('ENDL' , '\n ' ),
1727+ ('DEDENT' , '' ),
1728+ ], [
1729+ {
1730+ "type" : "try" ,
1731+ "first_formatting" : [],
1732+ "second_formatting" : [],
1733+ "else" : {},
1734+ "finally" : {},
1735+ "excepts" : [
1736+ {
1737+ "type" : "except" ,
1738+ "first_formatting" : [],
1739+ "second_formatting" : [],
1740+ "third_formatting" : [],
1741+ "fourth_formatting" : [],
1742+ "fifth_formatting" : [],
1743+ "delimiter" : "" ,
1744+ "target" : {},
1745+ "exception" : {},
1746+ "value" : [
1747+ {
1748+ "type" : "endl" ,
1749+ "formatting" : [],
1750+ "value" : "\n " ,
1751+ "indent" : " "
1752+ },
1753+ {
1754+ "type" : "pass" ,
1755+ },
1756+ {
1757+ "indent" : "" ,
1758+ "formatting" : [],
1759+ "type" : "endl" ,
1760+ "value" : "\n "
1761+ }
1762+ ]
1763+ }
1764+ ],
1765+ "value" : [
1766+ {
1767+ "type" : "pass" ,
1768+ },
1769+ {
1770+ "indent" : "" ,
1771+ "formatting" : [],
1772+ "type" : "endl" ,
1773+ "value" : "\n "
1774+ }
1775+ ],
1776+ }
1777+ ])
1778+
1779+ def test_try_excepts_stmt_empty_same_line_spaced ():
1780+ """
1781+ try: pass
1782+
1783+ except:
1784+ pass
1785+ """
1786+ parse_multi ([
1787+ ('TRY' , 'try' ),
1788+ ('COLON' , ':' ),
1789+ ('PASS' , 'pass' , [('SPACE' , ' ' )]),
1790+ ('ENDL' , '\n ' ),
1791+ ('ENDL' , '\n ' ),
1792+ ('EXCEPT' , 'except' ),
1793+ ('COLON' , ':' ),
1794+ ('ENDL' , '\n ' , [], [('SPACE' , ' ' )]),
1795+ ('INDENT' , '' ),
1796+ ('PASS' , 'pass' ),
1797+ ('ENDL' , '\n ' ),
1798+ ('DEDENT' , '' ),
1799+ ], [
1800+ {
1801+ "type" : "try" ,
1802+ "first_formatting" : [],
1803+ "second_formatting" : [],
1804+ "else" : {},
1805+ "finally" : {},
1806+ "excepts" : [
1807+ {
1808+ "type" : "except" ,
1809+ "first_formatting" : [],
1810+ "second_formatting" : [],
1811+ "third_formatting" : [],
1812+ "fourth_formatting" : [],
1813+ "fifth_formatting" : [],
1814+ "delimiter" : "" ,
1815+ "target" : {},
1816+ "exception" : {},
1817+ "value" : [
1818+ {
1819+ "type" : "endl" ,
1820+ "formatting" : [],
1821+ "value" : "\n " ,
1822+ "indent" : " "
1823+ },
1824+ {
1825+ "type" : "pass" ,
1826+ },
1827+ {
1828+ "indent" : "" ,
1829+ "formatting" : [],
1830+ "type" : "endl" ,
1831+ "value" : "\n "
1832+ }
1833+ ]
1834+ }
1835+ ],
1836+ "value" : [
1837+ {
1838+ "type" : "pass" ,
1839+ },
1840+ {
1841+ "indent" : "" ,
1842+ "formatting" : [],
1843+ "type" : "endl" ,
1844+ "value" : "\n "
1845+ }
1846+ ],
1847+ }
1848+ ])
1849+
0 commit comments