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.

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

821821 except TypeError:
822822 check = True
823823 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+ )
827833 return v
828834
829835 def __repr__(self):
845851 except TypeError:
846852 check = True
847853 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+ )
851863 return v
852864
853865 def __repr__(self):

The check that tells the two apart

failpass·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