Tweak when we delete LOAD_CONST RETURN_VALUE

This commit is contained in:
rocky
2024-11-28 08:03:32 -05:00
parent 74b39e2262
commit e4e3743de5

View File

@@ -1212,6 +1212,7 @@ class SourceWalker(GenericASTTraversal, NonterminalActions, ComprehensionMixin):
is_lambda=False, is_lambda=False,
noneInNames=False, noneInNames=False,
is_top_level_module=False, is_top_level_module=False,
compile_mode="exec",
) -> GenericASTTraversal: ) -> GenericASTTraversal:
# FIXME: DRY with fragments.py # FIXME: DRY with fragments.py
@@ -1262,7 +1263,6 @@ class SourceWalker(GenericASTTraversal, NonterminalActions, ComprehensionMixin):
load_const.kind == "LOAD_CONST" load_const.kind == "LOAD_CONST"
and load_const.linestart is None and load_const.linestart is None
and load_const.attr is None and load_const.attr is None
or is_top_level_module
): ):
# Delete LOAD_CONST (None) RETURN_VALUE # Delete LOAD_CONST (None) RETURN_VALUE
del tokens[-2:] del tokens[-2:]
@@ -1371,6 +1371,7 @@ def code_deparse(
co, co,
is_lambda=is_lambda_mode(compile_mode), is_lambda=is_lambda_mode(compile_mode),
is_top_level_module=is_top_level_module, is_top_level_module=is_top_level_module,
compile_mode=compile_mode,
) )
# XXX workaround for profiling # XXX workaround for profiling