Commit 89796e5
Fix bare string to SetManager silently shredding into characters
Every set-backed Constants argument is annotated Iterable[str], which a
bare str satisfies — as an iterable of its characters. SetManager's
set(elements) then silently replaced the whole default set with single
characters (Constants(titles='dr') -> titles == {'d', 'r'}), producing
wrong parses with no error anywhere. The type system cannot catch this,
so it must be a runtime check.
Reject str and bytes in SetManager.__init__ with a TypeError that
includes the wrap-it-in-a-list fix, covering all nine set-backed
Constants arguments and direct SetManager construction in one place.
All internal call sites pass module-level tuples/sets, and pickling
restores SetManager by state without re-running __init__, so only the
buggy input path is affected.
Closes #238
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 192d35e commit 89796e5
3 files changed
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
48 | 61 | | |
49 | 62 | | |
50 | 63 | | |
| |||
0 commit comments