Skip to content

[Bugfix] Fix raise with string literals in UCMBlendConnector#903

Open
SuperMarioYL wants to merge 1 commit intoModelEngine-Group:developfrom
SuperMarioYL:fix/blend-connector-raise-string-literals
Open

[Bugfix] Fix raise with string literals in UCMBlendConnector#903
SuperMarioYL wants to merge 1 commit intoModelEngine-Group:developfrom
SuperMarioYL:fix/blend-connector-raise-string-literals

Conversation

@SuperMarioYL
Copy link
Copy Markdown
Contributor

Purpose

Fix three raise "string" statements in UCMBlendConnector that produce TypeError at runtime instead of the intended error messages.

Modifications

In Python 3, raise "string" does not raise an exception with that message — it raises a TypeError: exceptions must derive from BaseException. This means callers never see the actual diagnostic text.

Line Before After
136 raise "UCMBlendConnector init failed, ..." raise ValueError("UCMBlendConnector init failed, ...")
330 raise "Please call setup model first." raise RuntimeError("Please call setup model first.")
339 raise "get cos_sin_cache from model failed! ..." raise RuntimeError("get cos_sin_cache from model failed! ...")
  • ValueError for the config validation (invalid configuration input)
  • RuntimeError for the precondition and model compatibility checks

Test

  • Verified black --check and isort --check pass on the modified file.
  • No new runtime behavior — only the exception type changes from TypeError to the correct type with the intended message.

In Python 3, `raise "string"` raises TypeError instead of the
intended error message. Replace all three occurrences with proper
exception types (ValueError / RuntimeError) so that callers receive
meaningful error messages when:

- Blend config is missing during connector initialization
- setup_model() was not called before post-processing chunk cache
- cos_sin_cache extraction fails for unsupported model architectures

Signed-off-by: supermario_leo <leo.stack@outlook.com>
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