Error in gluon parse_all_vars(): TypeError: write() argument must be str, not bytes

Skip to first unread message


Jun 23, 2023, 8:13:28 AMJun 23
to web2py-users
I'm running web2py Version 2.24.1-stable+timestamp.2023. with Python3.9 on Linux RHEL9. I have a web2py application that exposes a website to the public, it succesfully handles about 50 requests per second :)

Every day I see a few errors with this traceback:
Traceback (most recent call last):
File "/var/www/medios/gluon/", line 219, in restricted
exec(ccode, environment)
File "applications/lmdiario/compiled/", line 9, in <module>
File "/var/www/medios/applications/lmdiario/modules/", line 2300, in get_publicidades_response
layout = request.vars.layout or ''
File "/var/www/medios/gluon/", line 325, in vars
File "/var/www/medios/gluon/", line 296, in parse_all_vars
for key, value in iteritems(self.post_vars):
File "/var/www/medios/gluon/", line 317, in post_vars
File "/var/www/medios/gluon/", line 253, in parse_post_vars
dpost = cgi.FieldStorage(fp=body, environ=env, headers=headers, keep_blank_values=1)
File "/usr/lib64/python3.9/", line 482, in __init__
File "/usr/lib64/python3.9/", line 675, in read_single
File "/usr/lib64/python3.9/", line 697, in read_binary
TypeError: write() argument must be str, not bytes

I believe the error is related to this python bug: apparently the error occurs when receiving requests with Content-Length but without Content-Disposition headers

The errors are produced by random clients that send random POST requests. As the python bug is still opened, is there any way I can avoid this ticket errors? Using nginx to add the missing header? Changing web2py source code? What could I do?

Thanks in advance!
Warm regards,

Reply all
Reply to author
0 new messages