From 5b0986fe3036b9aa087c0c7f5b7750f2caa99428 Mon Sep 17 00:00:00 2001 From: UmranPros <152087084+umran666@users.noreply.github.com> Date: Mon, 15 Jun 2026 17:39:55 +0530 Subject: [PATCH] Fix version parsing NameError and older Python syntax compatibility (#6318) * Fix undefined variable 'e' in Version parsing exception * Fix SyntaxError for tuple unpacking in array index for Python < 3.11 --------- Co-authored-by: Lee Jackson <130007945+Imagineer99@users.noreply.github.com> --- unsloth/import_fixes.py | 2 +- unsloth/kernels/moe/tests/common.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unsloth/import_fixes.py b/unsloth/import_fixes.py index a100e11f0c..eb43666d56 100644 --- a/unsloth/import_fixes.py +++ b/unsloth/import_fixes.py @@ -49,7 +49,7 @@ def Version(version): new_version = str(version) new_version = re.match(r"[0-9\.]{1,}", new_version) if new_version is None: - raise Exception(str(e)) + raise ValueError(f"Could not parse version: {version}") new_version = new_version.group(0).rstrip(".") if new_version != version: new_version += ".1" # Add .1 for dev / alpha / beta / rc diff --git a/unsloth/kernels/moe/tests/common.py b/unsloth/kernels/moe/tests/common.py index 9d19fd4a18..f35a2fc9c3 100644 --- a/unsloth/kernels/moe/tests/common.py +++ b/unsloth/kernels/moe/tests/common.py @@ -158,8 +158,8 @@ def assert_close( ) bad_idxs = bad_idxs.unbind(-1) - print("ref values: ", ref[*bad_idxs].cpu()) - print("tri values: ", tri[*bad_idxs].cpu()) + print("ref values: ", ref[bad_idxs].cpu()) + print("tri values: ", tri[bad_idxs].cpu()) assert max_err <= maxtol assert rms_err <= rmstol