gh-134718: Fix ast.dump() for empty non-default values (GH-134926) · python/cpython@cc344e8

GitHub

@@ -1543,18 +1543,42 @@ def check_text(code, empty, full, **kwargs):

15431543full="MatchSingleton(value=None)",

15441544 )

154515451546+check_node(

1547+ast.MatchSingleton(value=[]),

1548+empty="MatchSingleton(value=[])",

1549+full="MatchSingleton(value=[])",

1550+ )

1551+15461552check_node(

15471553ast.Constant(value=None),

15481554empty="Constant(value=None)",

15491555full="Constant(value=None)",

15501556 )

155115571558+check_node(

1559+ast.Constant(value=[]),

1560+empty="Constant(value=[])",

1561+full="Constant(value=[])",

1562+ )

1563+15521564check_node(

15531565ast.Constant(value=''),

15541566empty="Constant(value='')",

15551567full="Constant(value='')",

15561568 )

155715691570+check_node(

1571+ast.Interpolation(value=ast.Constant(42), str=None, conversion=-1),

1572+empty="Interpolation(value=Constant(value=42), str=None, conversion=-1)",

1573+full="Interpolation(value=Constant(value=42), str=None, conversion=-1)",

1574+ )

1575+1576+check_node(

1577+ast.Interpolation(value=ast.Constant(42), str=[], conversion=-1),

1578+empty="Interpolation(value=Constant(value=42), str=[], conversion=-1)",

1579+full="Interpolation(value=Constant(value=42), str=[], conversion=-1)",

1580+ )

1581+15581582check_text(

15591583"def a(b: int = 0, *, c): ...",

15601584empty="Module(body=[FunctionDef(name='a', args=arguments(args=[arg(arg='b', annotation=Name(id='int', ctx=Load()))], kwonlyargs=[arg(arg='c')], kw_defaults=[None], defaults=[Constant(value=0)]), body=[Expr(value=Constant(value=Ellipsis))])])",