Skip to content

fix: prevent IndexError in mkconcore.py when arguments are missing (fixes #267)#308

Closed
GaneshPatil7517 wants to merge 3 commits intoControlCore-Project:devfrom
GaneshPatil7517:fix/mkconcore-arg-validation
Closed

fix: prevent IndexError in mkconcore.py when arguments are missing (fixes #267)#308
GaneshPatil7517 wants to merge 3 commits intoControlCore-Project:devfrom
GaneshPatil7517:fix/mkconcore-arg-validation

Conversation

@GaneshPatil7517
Copy link

@pradeeban

Summary

This PR resolves Issue #267 where mkconcore.py crashes with an IndexError when executed without required arguments.

The script accessed sys.argv[1], sys.argv[2], and sys.argv[3] before validating the number of arguments. As a result, running:

python mkconcore.py

produced:

IndexError: list index out of range

instead of a helpful usage message.

Changes Made

  • Moved argument length validation (len(sys.argv) < 4) before any access to sys.argv elements
  • Added clear usage message with print()
  • Added proper exit with non-zero status code (sys.exit(1))
  • Removed the now-redundant late validation block
  • No changes made to core logic or generation behavior

Behavior After Fix

  • Running without arguments now prints usage instructions and exits with code 1
  • Valid usage remains completely unaffected

Scope

  • Single-file modification: mkconcore.py
  • Minimal, focused change
  • No impact on concore-lite, Verilog, or any other modules

Copilot AI review requested due to automatic review settings February 14, 2026 07:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Issue #267 where mkconcore.py crashes with an IndexError when run without required command-line arguments. The script was accessing sys.argv[1], sys.argv[2], and sys.argv[3] before validating the argument count, causing crashes instead of displaying helpful usage information.

Changes:

  • Moved argument validation check (len(sys.argv) < 4) from line 157 to line 109, before any sys.argv access
  • Added usage message that displays when arguments are missing
  • Removed redundant late validation block that was unreachable

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pradeeban
Copy link
Member

Looks like many lines are changed without reason in addition to the actual change. Can you pls recreate the PR with the least number of lines changed? Probably this is a lone break change in many lines?

The minimal line changes will help avoid merge conflicts and maintain the actual author when a line was not really changed (helps with "git blame")

@pradeeban pradeeban closed this Feb 14, 2026
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.

2 participants