This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: cgi.FieldStorage is broken when given POST data
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: WSGI, cgi.FieldStorage incompatibility
View: 1573931
Assigned To: Nosy List: MHordecki, efosmark, eric.araujo, flox, milesck
Priority: normal Keywords:

Created on 2009-06-07 22:07 by efosmark, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg89060 - (view) Author: Evan Fosmark (efosmark) Date: 2009-06-07 22:07
Right now, it seems impossible to use cgi.FieldStorage in 3.0 if you're
giving it environ['wsgi.input'] like so:

    post_data = cgi.FieldStorage(

It gives the following error:

      File "/usr/local/lib/python3.0/", line 489, in __init__
      File "/usr/local/lib/python3.0/", line 589, in read_urlencoded
      File "/usr/local/lib/python3.0/urllib/", line 377, in
        pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
TypeError: Type str doesn't support the buffer API
msg92621 - (view) Author: Michal Hordecki (MHordecki) Date: 2009-09-14 16:49
It is because FieldStorage requires str, whereas wsgi.input gives bytes.

You can always wrap environ['wsgi.input'] in TextIOWrapper.
msg139646 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-07-02 13:41
Closing as duplicate.  The other report has more discussion.
Date User Action Args
2022-04-11 14:56:49adminsetgithub: 50483
2011-07-02 13:41:13eric.araujosetstatus: open -> closed

superseder: WSGI, cgi.FieldStorage incompatibility

nosy: + eric.araujo
messages: + msg139646
resolution: duplicate
stage: resolved
2010-08-27 14:56:26BreamoreBoysetversions: + Python 3.1, Python 2.7, Python 3.2, - Python 3.0
2010-08-27 03:19:27floxsetnosy: + flox
2009-09-14 16:49:23MHordeckisetnosy: + MHordecki
messages: + msg92621
2009-06-15 21:32:23milescksetnosy: + milesck
2009-06-07 22:07:35efosmarkcreate