fix: widen GLMProvider import exception to catch ImportError (zhipuai<2.0)#240
Open
Jah-yee wants to merge 1 commit into
Open
fix: widen GLMProvider import exception to catch ImportError (zhipuai<2.0)#240Jah-yee wants to merge 1 commit into
Jah-yee wants to merge 1 commit into
Conversation
…<2.0) When zhipuai<2.0 is installed, 'from zhipuai import ZhipuAI' raises ImportError (not ModuleNotFoundError) because the ZhipuAI symbol moved across major versions. The narrow 'except ModuleNotFoundError' clause does not catch this, causing ClawcodexREPL(provider_name='glm') to crash at import time. Widen to 'except ImportError' which covers both cases. Fixes agentforce314#166.
Author
|
Happy to help widen the exception handler! GLMProvider should handle both ModuleNotFoundError and ImportError for zhipuai versions < 2.0 — this is a clean one-line fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: widen GLMProvider import exception to catch ImportError
Problem
When is installed,
from zhipuai import ZhipuAIraises a bareImportError(notModuleNotFoundError) because theZhipuAIsymbol was moved across major versions. The narrowexcept ModuleNotFoundErrorclause doesn't catch this, causingClawcodexREPL(provider_name='glm')to crash at import time.Fix
Widen the exception clause from
ModuleNotFoundErrortoImportError(its superclass), which catches both:ModuleNotFoundError— zhipuai not installedImportError— zhipuai installed butZhipuAIsymbol not found (e.g. zhipuai<2.0)Fixes #166.
Verification
python3 -m py_compile src/providers/glm_provider.py✅Diff