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
{{ message }}
Repository navigation
cgi: TypeError when no argument string is found #76210
bpo-27777: cgi.FieldStorage can't parse simple body with Content-Length and no Content-Disposition
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2017-11-15.01:53:55.106>created_at=<Date2017-11-15.00:31:53.576>labels= ['type-bug', 'library']
title='cgi: TypeError when no argument string is found'updated_at=<Date2017-11-15.01:53:55.097>user='https://github.com/srittau'
Traceback (most recent call last):
File "foo.py", line 7, in <module>"CONTENT_LENGTH": "14",
File "/usr/lib/python3.6/cgi.py", line 561, in __init__self.read_single()
File "/usr/lib/python3.6/cgi.py", line 740, in read_singleself.read_binary()
File "/usr/lib/python3.6/cgi.py", line 762, in read_binaryself.file.write(data)
TypeError: write() argument must be str, not bytes
Of course, the input does not contain any argument string to be parsed by FieldStorage. Nevertheless, a TypeError in a totally unrelated part of the code seems like a bug. In my opinion, FieldStorage should just remain empty in this case, or - at best - throw a ValueError with a sensible error message.
Thank you for your report. This looks like a duplicate of bpo-27777. You might workaround this by passing headers={"Content-Disposition": "inline"} to cgi.FieldStorage() (untested)
Activity
srittau commentedon Nov 15, 2017
Consider the following code:
This will throw the following exception:
Of course, the input does not contain any argument string to be parsed by FieldStorage. Nevertheless, a TypeError in a totally unrelated part of the code seems like a bug. In my opinion, FieldStorage should just remain empty in this case, or - at best - throw a ValueError with a sensible error message.
[-]cgi: TypeError[/-][+]cgi: TypeError when no argument string is found[/+]berkerpeksag commentedon Nov 15, 2017
Thank you for your report. This looks like a duplicate of bpo-27777. You might workaround this by passing
headers={"Content-Disposition": "inline"}to cgi.FieldStorage() (untested)