Skip to content

Fix version parsing NameError and older Python syntax compatibility#6318

Merged
Imagineer99 merged 7 commits into
unslothai:mainfrom
umran666:fix-version-parsing-error
Jun 15, 2026
Merged

Fix version parsing NameError and older Python syntax compatibility#6318
Imagineer99 merged 7 commits into
unslothai:mainfrom
umran666:fix-version-parsing-error

Conversation

@umran666

Copy link
Copy Markdown
Contributor

I was running some static analysis on the codebase and found a couple of minor but critical bugs which are:

  1. Fixed a crash in import_fixes.py:
    In Version(), if an invalid version string was passed, the exception handler was trying to raise Exception(str(e)). However, the variable e was unbound, which would cause a secondary NameError and hide the actual parsing issue. I replaced this with a clean ValueError(f"Could not parse version: {version}").

  2. Fixed a Python < 3.11 SyntaxError in kernels/moe/tests/common.py:
    In assert_indx_equal / the MoE tests, there was an unpacked tuple inside an array index (ref[*bad_idxs]). This syntax isn't supported in Python 3.9/3.10 and causes a hard syntax error. I removed the asterisk to use standard indexing (ref[bad_idxs]), which restores compatibility across all supported Python versions.

@umran666 umran666 requested a review from danielhanchen as a code owner June 14, 2026 15:04

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request resolves a bug in unsloth/import_fixes.py where an undefined variable e was referenced when raising an exception, replacing it with a clear ValueError. Additionally, it corrects tensor indexing in unsloth/kernels/moe/tests/common.py by removing the unpacking operator * from bad_idxs. No review comments were provided, so there is no feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@Imagineer99 Imagineer99 self-assigned this Jun 14, 2026
@Imagineer99

Copy link
Copy Markdown
Collaborator
image CI passes on staging fork.

@Imagineer99 Imagineer99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tested and works as expected. Verified the Python 3.9/3.10 syntax issue is fixed, the changed tensor indexing preserves behavior, and invalid version parsing now reports the intended underlying error instead of the secondary NameError. Merging.

@Imagineer99 Imagineer99 merged commit 5b0986f into unslothai:main Jun 15, 2026
1 check passed
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