Whole file
alecthomas/voluptuous
The author described this change as “fix: allow unsortable containers in In and NotIn validators (fixes #451) (#506)”. It counts as a record because the check below fails on the code as it stood at 09d0f066a and passes on 503dd346a, with nothing else changed between the two runs.
Projectalecthomas/voluptuous
Fix saved2024-02-01
Sharing licenceBSD-3-Clause · COPYING
Change size+18 −6
What the code was meant to do, written into the code itself as a save note
fix: allow unsortable containers in In and NotIn validators (fixes #451) (#506)
The change
| 821 | 821 | except TypeError: | |
| 822 | 822 | check = True | |
| 823 | 823 | if check: | |
| 824 | - | raise InInvalid( | |
| 825 | - | self.msg or 'value must be one of {}'.format(sorted(self.container)) | |
| 826 | - | ) | |
| 824 | + | try: | |
| 825 | + | raise InInvalid( | |
| 826 | + | self.msg or f'value must be one of {sorted(self.container)}' | |
| 827 | + | ) | |
| 828 | + | except TypeError: | |
| 829 | + | raise InInvalid( | |
| 830 | + | self.msg | |
| 831 | + | or f'value must be one of {sorted(self.container, key=str)}' | |
| 832 | + | ) | |
| 827 | 833 | return v | |
| 828 | 834 | ||
| 829 | 835 | def __repr__(self): | |
| ⋯ | |||
| 845 | 851 | except TypeError: | |
| 846 | 852 | check = True | |
| 847 | 853 | if check: | |
| 848 | - | raise NotInInvalid( | |
| 849 | - | self.msg or 'value must not be one of {}'.format(sorted(self.container)) | |
| 850 | - | ) | |
| 854 | + | try: | |
| 855 | + | raise NotInInvalid( | |
| 856 | + | self.msg or f'value must not be one of {sorted(self.container)}' | |
| 857 | + | ) | |
| 858 | + | except TypeError: | |
| 859 | + | raise NotInInvalid( | |
| 860 | + | self.msg | |
| 861 | + | or f'value must not be one of {sorted(self.container, key=str)}' | |
| 862 | + | ) | |
| 851 | 863 | return v | |
| 852 | 864 | ||
| 853 | 865 | def __repr__(self): | |
The check that tells the two apart
fail→pass·voluptuous/tests/tests.py::test_in_unsortable_container
Check file voluptuous/tests/tests.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it09d0f066a5f7b80973996c90c54a7bb00f62c905
Broken version dated2024-01-31
Modulevoluptuous.validators
Units changedIn, NotIn
Fingerprintb9f87d90fa2f99f9
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in alecthomas/voluptuous
- 2026-07-11Number
- 2026-07-04Number
- 2025-04-30Fix bug with Any validator and REMOVE_EXTRA (#524)
- 2024-06-23Fix vol.Remove not removing keys that do not validate (#515)