Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgi.FieldStorage is broken when given POST data #50483

Closed
efosmark mannequin opened this issue Jun 7, 2009 · 3 comments
Closed

cgi.FieldStorage is broken when given POST data #50483

efosmark mannequin opened this issue Jun 7, 2009 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@efosmark
Copy link
Mannequin

efosmark mannequin commented Jun 7, 2009

BPO 6234
Nosy @merwok, @florentx
Superseder
  • bpo-1573931: WSGI, cgi.FieldStorage incompatibility
  • 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 = None
    closed_at = <Date 2011-07-02.13:41:13.797>
    created_at = <Date 2009-06-07.22:07:35.364>
    labels = ['type-bug', 'library']
    title = 'cgi.FieldStorage is broken when given POST data'
    updated_at = <Date 2011-07-02.13:41:13.795>
    user = 'https://bugs.python.org/efosmark'

    bugs.python.org fields:

    activity = <Date 2011-07-02.13:41:13.795>
    actor = 'eric.araujo'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-07-02.13:41:13.797>
    closer = 'eric.araujo'
    components = ['Library (Lib)']
    creation = <Date 2009-06-07.22:07:35.364>
    creator = 'efosmark'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 6234
    keywords = []
    message_count = 3.0
    messages = ['89060', '92621', '139646']
    nosy_count = 5.0
    nosy_names = ['eric.araujo', 'efosmark', 'milesck', 'MHordecki', 'flox']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '1573931'
    type = 'behavior'
    url = 'https://bugs.python.org/issue6234'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    @efosmark
    Copy link
    Mannequin Author

    efosmark mannequin commented Jun 7, 2009

    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(
            fp=environ["wsgi.input"],
            environ=environ,
            keep_blank_values=True
            )

    It gives the following error:

      File "/usr/local/lib/python3.0/cgi.py", line 489, in \_\_init__
        self.read_urlencoded()
      File "/usr/local/lib/python3.0/cgi.py", line 589, in read_urlencoded
        self.strict_parsing):
      File "/usr/local/lib/python3.0/urllib/parse.py", line 377, in
    

    parse_qsl
    pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
    TypeError: Type str doesn't support the buffer API

    @efosmark efosmark mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 7, 2009
    @MHordecki
    Copy link
    Mannequin

    MHordecki mannequin commented Sep 14, 2009

    It is because FieldStorage requires str, whereas wsgi.input gives bytes.

    You can always wrap environ['wsgi.input'] in TextIOWrapper.

    @merwok
    Copy link
    Member

    merwok commented Jul 2, 2011

    Closing as duplicate. The other report has more discussion.

    @merwok merwok closed this as completed Jul 2, 2011
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant