Originally reported by: Juern Brodersen (Bitbucket: juern_uni, GitHub: Unknown)
If you are using 'enctype="multipart/form-data"' in forms and putting more than around 1000 characters in a text field that text field will be returned as a byte object.
Using less characters in the text field will return a string.
#!python
import cherrypy
class StringGenerator(object):
@cherrypy.expose
def index(self):
return """<html>
<head></head>
<body>
<form method="post" action="show" enctype="multipart/form-data">
<textarea type="text" name="textarea" cols="50" rows="10"></textarea>
<button type="submit">Give it now!</button>
</form>
</body>
</html>"""
@cherrypy.expose
def show(self, **kw):
a = str(type(kw['textarea']))
return a[1:-1]
if __name__ == '__main__':
cherrypy.quickstart(StringGenerator())
Less than 1000 characters will return "class 'str'" more returns "class 'bytes'"
Tested with:
python 3.4
cherrypy 3.6
Originally reported by: Juern Brodersen (Bitbucket: juern_uni, GitHub: Unknown)
If you are using 'enctype="multipart/form-data"' in forms and putting more than around 1000 characters in a text field that text field will be returned as a byte object.
Using less characters in the text field will return a string.
Less than 1000 characters will return "class 'str'" more returns "class 'bytes'"
Tested with:
python 3.4
cherrypy 3.6