8000 gh-116000: Make ``Tools/cases_generator/optimizer_generator.py`` work without any arguments by Eclips4 · Pull Request #116470 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-116000: Make Tools/cases_generator/optimizer_generator.py work without any arguments #116470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Tools/cases_generator/optimizer_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from stack import Stack, SizeMismatch, UNUSED

DEFAULT_OUTPUT = ROOT / "Python/optimizer_cases.c.h"
DEFAULT_ABSTRACT_INPUT = ROOT / "Python/optimizer_bytecodes.c"
DEFAULT_ABSTRACT_INPUT = (ROOT / "Python/optimizer_bytecodes.c").absolute().as_posix()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is needed because of parser/prettify_filename which works only with an str type.



def validate_uop(override: Uop, uop: Uop) -> None:
Expand Down Expand Up @@ -214,19 +214,22 @@ def generate_tier2_abstract_from_files(
)


arg_parser.add_argument("input", nargs=1, help="Abstract interpreter definition file")
arg_parser.add_argument("input", nargs='*', help="Abstract interpreter definition file")

arg_parser.add_argument(
"base", nargs=argparse.REMAINDER, help="The base instruction definition file(s)"
"base", nargs="*", help="The base instruction definition file(s)"
)

arg_parser.add_argument("-d", "--debug", help="Insert debug calls", action="store_true")

if __name__ == "__main__":
args = arg_parser.parse_args()
if len(args.base) == 0:
args.input.append(DEFAULT_INPUT)
if not args.input:
args.base.append(DEFAULT_INPUT)
args.input.append(DEFAULT_ABSTRACT_INPUT)
else:
args.base.append(args.input[-1])
args.input.pop()
abstract = analyze_files(args.input)
base = analyze_files(args.base)
with open(args.output, "w") as outfile:
Expand Down
3995
0