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
Using Pyramid and Python 3.4.
When I leave an input type="file" name="file" empty, the request.POST has {'file': b' '}.
b' ' is iterable, so formencode raises singleValueExpected=_('Please provide only one value')
Python 3.4.3 (default, Jul 28 2015, 18:20:59)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from formencode import Schema, validators
>>> class FileSchema(Schema):
... file = validators.FieldStorageUploadConverter()
...
>>> FileSchema().to_python({"file": b''})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aj/.virtualenvs/marketplace/lib/python3.4/site-packages/formencode/api.py", line 476, in to_python
value = tp(value, state)
File "/home/aj/.virtualenvs/marketplace/lib/python3.4/site-packages/formencode/schema.py", line 217, in _convert_to_python
value_dict, state, error_dict=errors)
formencode.api.Invalid: file: Please provide only one value
>>>
The text was updated successfully, but these errors were encountered:
We are explicitly checking for basestring, which seems like it's not the right thing to do on Python 3. I'm investigating what other string-likes we need in order to make it work.
valos
added a commit
to valos/formencode
that referenced
this issue
Dec 17, 2018
this got detected by one of my test suites today. it was a pain to figure out. the fix deployed by @valos above passed out tests without triggering new issues.
jvanasco
added a commit
to jvanasco/formencode
that referenced
this issue
Sep 25, 2020
Using Pyramid and Python 3.4.
When I leave an input type="file" name="file" empty, the request.POST has {'file': b' '}.
b' ' is iterable, so formencode raises singleValueExpected=_('Please provide only one value')
The text was updated successfully, but these errors were encountered: