Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use sorted() #451

Closed
Avorthoren opened this issue Mar 18, 2022 · 0 comments · Fixed by #506
Closed

Do not use sorted() #451

Avorthoren opened this issue Mar 18, 2022 · 0 comments · Fixed by #506

Comments

@Avorthoren
Copy link

Version 12.1 (commit 111e1c2) adds call of sorted function. This leads to application crash when schema container contains not comparable pair of elements. Example:

>>> import voluptuous as vlps
>>> s = vlps.Schema(vlps.In((str, int, float)))
>>> d = s(42)
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 3, in <module>
  File ".../lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File ".../lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File ".../lib/python3.9/site-packages/voluptuous/validators.py", line 741, in __call__
    'value must be one of {}'.format(sorted(self.container)))
TypeError: '<' not supported between instances of 'type' and 'type'

This function should not be used, as it limits the possibilities of use without giving anything in return.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant