Skip to content

Fix CLI execution namespace and argument handling - #9

Open
valko1 wants to merge 1 commit into
fless-lab:masterfrom
valko1:fix/cli-execution
Open

valko1 wants to merge 1 commit into
fless-lab:masterfrom
valko1:fix/cli-execution

Conversation

@valko1

@valko1 valko1 commented Nov 4, 2026

Copy link
Copy Markdown

Summary

Fix recursive function execution in Multilang-Python and improve CLI argument handling.

Changes

  • Fix recursive function execution by using an explicit shared namespace for exec().
  • Compile translated code with the source filename for more informative tracebacks.
  • Add --help and -h support.
  • Fix --version to exit successfully.
  • Improve error handling and exit codes.
  • Provide standard execution metadata (__name__, __file__, __package__).

Problem Fixed

Previously, translated Python code was executed using:

exec(translated_code)

Recursive functions could fail with NameError because their definitions were not available in the execution's global namespace.

The implementation now uses:

exec(compiled_code, namespace, namespace)

This ensures that functions, including recursive functions, can resolve their global references correctly.

Testing

Environment: Windows 11 ARM64, Python 3.14.

  • Python syntax compilation: PASSED.
  • CLI --help: PASSED.
  • CLI --version: PASSED.
  • CLI --list-langs: PASSED.
  • Bulgarian recursive factorial example: PASSED.

Scope

This fix is language-independent and does not modify any language configuration files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant