[ python-Bugs-833405 ] urllib.urlencode doesn't work for output from cgi.parse_qs

SourceForge.net noreply at sourceforge.net
Sat Apr 3 20:19:40 EST 2004


Bugs item #833405, was opened at 2003-10-30 17:39
Message generated for change (Comment added) made by myers_carpenter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=833405&group_id=5470

Category: None
Group: None
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Myers Carpenter (myers_carpenter)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib.urlencode doesn't work for output from cgi.parse_qs

Initial Comment:
>>>
urllib.urlencode(cgi.parse_qsl('ext=.jpg&outquality=56'))
'ext=.jpg&outquality=56'
>>>
urllib.urlencode(cgi.parse_qs('ext=.jpg&outquality=56'))
'ext=%5B%27.jpg%27%5D&outquality=%5B%2756%27%5D'

"%5B%27" = "['"

 

----------------------------------------------------------------------

>Comment By: Myers Carpenter (myers_carpenter)
Date: 2004-04-03 20:19

Message:
Logged In: YES 
user_id=335935

Ok... closing

----------------------------------------------------------------------

Comment By: Mike Brown (mike_j_brown)
Date: 2004-04-01 16:13

Message:
Logged In: YES 
user_id=371366

I am only guessing, here, but if you had an object that you 
wanted to embed a representation of in a URL or in HTML 
form data, it would be prudent to call str() on the object and 
let its __str__ method give you a string representation, and 
then you'd percent-encode that. This makes sense for user-
defined classes, where you can define __str__, but not for 
built-in types like an ordinary list, so they give you the doseq 
flag for those situations.

----------------------------------------------------------------------

Comment By: Myers Carpenter (myers_carpenter)
Date: 2004-03-31 11:56

Message:
Logged In: YES 
user_id=335935

Can you name one web app that you know will take args in the
form of "ext=[27.jpg]"?  Why not do some type inspection to
see what types you are dealing with?  What is the use of
encoding a list in a url using python syntax?

----------------------------------------------------------------------

Comment By: Mike Brown (mike_j_brown)
Date: 2004-03-31 01:01

Message:
Logged In: YES 
user_id=371366

As per the urlencode() API documentation, you are passing in 
sequences, so you need to set the doseq flag.

>>> urllib.urlencode(cgi.parse_qs
('ext=.jpg&outquality=56'),doseq=1)
'ext=.jpg&outquality=56'

I recommend that this bug report be closed as Invalid.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=833405&group_id=5470



More information about the Python-bugs-list mailing list