[PR #366] [MERGED] Fix: Prevent TypeError: 'NoneType' is not iterable on model switching #360

Closed
opened 2026-11-07 17:43:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Physton/sd-webui-prompt-all-in-one/pull/366
Author: @neon-aiart
Created: 11/3/2025
Status: ✅ Merged
Merged: 11/10/2025
Merged by: @Physton

Base: main ← Head: main


📝 Commits (5)

  • 9e1ced6 Fix: Prevent TypeError: 'NoneType' is not iterable on model switching (Forge/reForge)
  • d786590 Update get_token_counter.py
  • 8bf3dba FIX: Safely handle None model data during model switching to prevent TypeError in token counter
  • 0aa3c04 Update get_token_counter.py
  • fea3070 FIX: Prevent TypeError: NoneType on model switching in token counter

📊 Changes

1 file changed (+4 additions, -0 deletions)

View changed files

📝 scripts/physton_prompt/get_token_counter.py (+4 -0)

📄 Description

This fixes the TypeError that occurs during model switching in sd-webui-reforge and possibly other optimized environments.

The error happens because 'get_token_counter' tries to access 'sd_models.model_data.sd_model.cond_stage_model' before the model is fully loaded (when 'sd_model' is None).

The fix adds a check for the 'None' value to safely return 0 tokens instead of throwing an error.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Physton/sd-webui-prompt-all-in-one/pull/366 **Author:** [@neon-aiart](https://github.com/neon-aiart) **Created:** 11/3/2025 **Status:** ✅ Merged **Merged:** 11/10/2025 **Merged by:** [@Physton](https://github.com/Physton) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (5) - [`9e1ced6`](https://github.com/Physton/sd-webui-prompt-all-in-one/commit/9e1ced64388d6fa979da3ffc174b7d0837d2f86f) Fix: Prevent TypeError: 'NoneType' is not iterable on model switching (Forge/reForge) - [`d786590`](https://github.com/Physton/sd-webui-prompt-all-in-one/commit/d7865901ec7d2aff0a46276bff017498adbec835) Update get_token_counter.py - [`8bf3dba`](https://github.com/Physton/sd-webui-prompt-all-in-one/commit/8bf3dbad47c15f52dc35d6f62734a58a1d8f191f) FIX: Safely handle None model data during model switching to prevent TypeError in token counter - [`0aa3c04`](https://github.com/Physton/sd-webui-prompt-all-in-one/commit/0aa3c04de431c41e4fd149ff83be23593c5c2d4c) Update get_token_counter.py - [`fea3070`](https://github.com/Physton/sd-webui-prompt-all-in-one/commit/fea3070a40570499d186552c7b0dcea671f044e1) FIX: Prevent TypeError: NoneType on model switching in token counter ### 📊 Changes **1 file changed** (+4 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `scripts/physton_prompt/get_token_counter.py` (+4 -0) </details> ### 📄 Description This fixes the TypeError that occurs during model switching in sd-webui-reforge and possibly other optimized environments. The error happens because 'get_token_counter' tries to access 'sd_models.model_data.sd_model.cond_stage_model' before the model is fully loaded (when 'sd_model' is None). The fix adds a check for the 'None' value to safely return 0 tokens instead of throwing an error. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:43:46 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Physton/sd-webui-prompt-all-in-one#360
No description provided.