Skip to content

fix: handle list input for special_tokens (#47110)#47416

Closed
webtecnica wants to merge 2 commits into
huggingface:mainfrom
webtecnica:fix/47110-special-tokens-list
Closed

fix: handle list input for special_tokens (#47110)#47416
webtecnica wants to merge 2 commits into
huggingface:mainfrom
webtecnica:fix/47110-special-tokens-list

Conversation

@webtecnica

@webtecnica webtecnica commented Jul 19, 2026

Copy link
Copy Markdown

CI

What this PR does

Fixes #47110

Adds a TypeError guard in add_special_tokens to handle the case when a list is passed as special_tokens_dict instead of a dict. Previously, passing a list would raise a cryptic 'list' object has no attribute 'keys' (or ValueError: dictionary update sequence element has length...). Now it raises a clear TypeError with guidance on the expected format.

Who can review?

@ArthurZucker @itazap

webtecnica added 2 commits July 19, 2026 10:48
…e#47110)

Prevents AttributeError when special_tokens is passed as a list instead of dict
by checking isinstance before calling .keys().
@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 29689682453:2
Result: failure | Jobs: 15 | Tests: 172,139 | Failures: 2 | Duration: 14h 32m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

special_tokens, 'list' object has no attribute 'keys'

2 participants