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

48 views
Skip to first unread message

Lisandro

unread,
Jun 23, 2023, 8:13:28 AMJun 23
to web2py-users
I'm running web2py Version 2.24.1-stable+timestamp.2023.03.23.05.07.17 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/restricted.py", line 219, in restricted
exec(ccode, environment)
File "applications/lmdiario/compiled/controllers.default.index.py", line 9, in <module>
File "/var/www/medios/applications/lmdiario/modules/globales.py", line 2300, in get_publicidades_response
layout = request.vars.layout or ''
File "/var/www/medios/gluon/globals.py", line 325, in vars
self.parse_all_vars()
File "/var/www/medios/gluon/globals.py", line 296, in parse_all_vars
for key, value in iteritems(self.post_vars):
File "/var/www/medios/gluon/globals.py", line 317, in post_vars
self.parse_post_vars()
File "/var/www/medios/gluon/globals.py", line 253, in parse_post_vars
dpost = cgi.FieldStorage(fp=body, environ=env, headers=headers, keep_blank_values=1)
File "/usr/lib64/python3.9/cgi.py", line 482, in __init__
self.read_single()
File "/usr/lib64/python3.9/cgi.py", line 675, in read_single
self.read_binary()
File "/usr/lib64/python3.9/cgi.py", line 697, in read_binary
self.file.write(data)
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,
Lisandro


Reply all
Reply to author
Forward
0 new messages