You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normalize SetManager constructor elements and validate element types
Review follow-up on the operand-normalization commit: the constructor
still stored raw elements, which that commit turned from a latent
inconsistency into active misfires — SetManager(['Dr.']) & ['Dr.']
returned empty and - silently no-opped against the exact spelling
stored in the set, Constants(titles=[...]) remained the last
silently-dead config path (raw 'Chemistry' can never match the
parser's lc() lookups), and titles vs the suffixes_prefixes_titles
union disagreed about the same token.
Fold the operand helper into _normalized_elements, shared by __init__
and all operators, so every entry is stored in the form lookups expect.
Junk elements now raise a curated TypeError instead of failing
cryptically inside lc() (bytes, int) or being silently transmuted
(None became '').
Also scope the docstring claim that operators normalize "the same way
add() does" (add() additionally decodes bytes), correct "strips
periods" to leading/trailing in prose, and pin __rxor__ separately.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/release_log.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ Release Log
2
2
===========
3
3
* 1.3.0 - Unreleased
4
4
- Fix a bare string passed to a set-backed ``Constants`` argument (e.g. ``Constants(titles='dr')``), to ``SetManager``, or as a ``SetManager`` set-operator operand (e.g. ``constants.titles |= 'esq'``) being silently split into single characters, replacing or polluting the set and producing wrong parses with no error; it now raises ``TypeError`` with the suggested fix — wrap strings in a list, decode ``bytes`` first (closes #238)
5
-
- Fix ``SetManager`` set operators skipping the lowercase/strip-periods normalization that ``add()`` applies: ``constants.titles |= ['Esq.']`` kept a raw ``'Esq.'`` the parser's lookups could never match, and ``titles & ['Dr.']`` missed ``'dr'``; operator operands are now normalized, so operator results behave like ``add()``-built sets
5
+
- Fix ``SetManager`` set operators and the constructor skipping the lowercase/strip-edge-periods normalization that ``add()`` applies: ``constants.titles |= ['Esq.']`` kept a raw ``'Esq.'`` the parser's lookups could never match, ``titles & ['Dr.']`` missed ``'dr'``, and ``Constants(titles=[...])`` stored raw elements that silently never matched; elements and operands are now normalized everywhere, and non-``str`` elements (``bytes``, ``None``, numbers) raise ``TypeError`` instead of crashing cryptically or being coerced
6
6
- Fix the ``constants`` constructor argument silently discarding ``Constants`` *subclass* instances: the exact-type check replaced them with fresh defaults, throwing away the caller's configuration. Subclass instances are now used as given; anything that is neither ``None`` nor a ``Constants`` instance now raises ``TypeError`` instead of being silently swapped for defaults (closes #226)
7
7
- Fix ``IndexError`` in ``initials()``/``initials_list()`` when a ``*_list`` attribute was assigned directly with an element containing unnormalized whitespace (e.g. ``name.middle_list = ['Q R']``), bypassing the parser's whitespace normalization (closes #232)
8
8
- Fix ``HumanName`` acting as its own iterator with a stored cursor: breaking out of a loop, iterating in nested loops, or calling ``len(name)`` mid-loop corrupted subsequent iteration; ``iter(name)`` now returns a fresh independent iterator each time. ``next(name)`` on the instance itself (undocumented) now raises ``TypeError`` — call ``next(iter(name))`` instead (closes #225)
0 commit comments