Copying cgi.parse_qs() to the urllib.parse module

I just realized that PEP 3108 was missing one proposal from the stdlib SIG (originally proposed by Facundo Batista) of copying the cgi.parse_qs() function over to the new urllib.parse module so that people no longer need to import the cgi module just for that one parsing function. Does anyone object if I update the PEP to include that change?
-Brett

Works for me. The other thing I always use from cgi is escape() -- will that be available somewhere else too?
On Sat, May 10, 2008 at 8:30 PM, Brett Cannon brett@python.org wrote:
I just realized that PEP 3108 was missing one proposal from the stdlib SIG (originally proposed by Facundo Batista) of copying the cgi.parse_qs() function over to the new urllib.parse module so that people no longer need to import the cgi module just for that one parsing function. Does anyone object if I update the PEP to include that change?

On May 10, 2008, at 11:49 PM, Guido van Rossum wrote:
Works for me. The other thing I always use from cgi is escape() -- will that be available somewhere else too?
xml.sax.saxutils.escape() would be an appropriate replacement, though the location is a little funky.
-Fred

Fred Drake schrieb:
On May 10, 2008, at 11:49 PM, Guido van Rossum wrote:
Works for me. The other thing I always use from cgi is escape() -- will that be available somewhere else too?
xml.sax.saxutils.escape() would be an appropriate replacement, though the location is a little funky.
Ideally it would be xml.escape(). Perhaps there are more of these generally- useful XML thingies to put there?
Georg

On Sun, May 11, 2008 at 12:00 AM, Georg Brandl g.brandl@gmx.net wrote:
Fred Drake schrieb:
On May 10, 2008, at 11:49 PM, Guido van Rossum wrote:
Works for me. The other thing I always use from cgi is escape() -- will that be available somewhere else too?
xml.sax.saxutils.escape() would be an appropriate replacement, though the location is a little funky.
More than a little IMO. :-(
Ideally it would be xml.escape(). Perhaps there are more of these generally- useful XML thingies to put there?
Not really -- I'd rather see the xml package as a pure container, with all its contents in submodules (or subpackages).
Also, I don't see this exclusive to XML -- HTML isn't XML (yet).
Georg
-- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.
Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org

On Sun, May 11, 2008 at 4:43 PM, Guido van Rossum guido@python.org wrote:
On Sun, May 11, 2008 at 12:00 AM, Georg Brandl g.brandl@gmx.net wrote:
Fred Drake schrieb:
On May 10, 2008, at 11:49 PM, Guido van Rossum wrote:
Works for me. The other thing I always use from cgi is escape() -- will that be available somewhere else too?
xml.sax.saxutils.escape() would be an appropriate replacement, though the location is a little funky.
More than a little IMO. :-(
Well, if that function is better than who cares about the location; it will end up in urllib.parse as some function.
-Brett

On Sun, May 11, 2008 at 5:01 PM, Brett Cannon brett@python.org wrote:
On Sun, May 11, 2008 at 4:43 PM, Guido van Rossum guido@python.org wrote:
On Sun, May 11, 2008 at 12:00 AM, Georg Brandl g.brandl@gmx.net wrote:
Fred Drake schrieb:
On May 10, 2008, at 11:49 PM, Guido van Rossum wrote:
Works for me. The other thing I always use from cgi is escape() -- will that be available somewhere else too?
xml.sax.saxutils.escape() would be an appropriate replacement, though the location is a little funky.
More than a little IMO. :-(
Well, if that function is better than who cares about the location; it will end up in urllib.parse as some function.
It's a trivial function; it shouldn't pull in three packages and lots of other cruft.

On Sun, May 11, 2008 at 6:23 PM, Guido van Rossum guido@python.org wrote:
On Sun, May 11, 2008 at 5:01 PM, Brett Cannon brett@python.org wrote:
On Sun, May 11, 2008 at 4:43 PM, Guido van Rossum guido@python.org wrote:
On Sun, May 11, 2008 at 12:00 AM, Georg Brandl g.brandl@gmx.net wrote:
Fred Drake schrieb:
On May 10, 2008, at 11:49 PM, Guido van Rossum wrote:
Works for me. The other thing I always use from cgi is escape() -- will that be available somewhere else too?
xml.sax.saxutils.escape() would be an appropriate replacement, though the location is a little funky.
More than a little IMO. :-(
Well, if that function is better than who cares about the location; it will end up in urllib.parse as some function.
It's a trivial function; it shouldn't pull in three packages and lots of other cruft.
So are you saying that it isn't that much better in urllib.parse? That only cuts the package count down by one.
-Brett

On Sun, May 11, 2008 at 6:34 PM, Brett Cannon brett@python.org wrote:
On Sun, May 11, 2008 at 6:23 PM, Guido van Rossum guido@python.org wrote:
On Sun, May 11, 2008 at 5:01 PM, Brett Cannon brett@python.org wrote:
On Sun, May 11, 2008 at 4:43 PM, Guido van Rossum guido@python.org wrote:
On Sun, May 11, 2008 at 12:00 AM, Georg Brandl g.brandl@gmx.net wrote:
Fred Drake schrieb:
On May 10, 2008, at 11:49 PM, Guido van Rossum wrote: > > Works for me. The other thing I always use from cgi is escape() -- > will that be available somewhere else too?
xml.sax.saxutils.escape() would be an appropriate replacement,
though the
location is a little funky.
More than a little IMO. :-(
Well, if that function is better than who cares about the location; it will end up in urllib.parse as some function.
It's a trivial function; it shouldn't pull in three packages and lots of other cruft.
So are you saying that it isn't that much better in urllib.parse? That only cuts the package count down by one.
I didn't mean to say, but it does seem the wrong module -- escape() is for HTML, not for URLs.

On Sun, May 11, 2008 at 6:35 PM, Guido van Rossum guido@python.org wrote:
On Sun, May 11, 2008 at 6:34 PM, Brett Cannon brett@python.org wrote:
On Sun, May 11, 2008 at 6:23 PM, Guido van Rossum guido@python.org wrote:
On Sun, May 11, 2008 at 5:01 PM, Brett Cannon brett@python.org wrote:
On Sun, May 11, 2008 at 4:43 PM, Guido van Rossum guido@python.org wrote:
On Sun, May 11, 2008 at 12:00 AM, Georg Brandl g.brandl@gmx.net wrote:
Fred Drake schrieb: > > On May 10, 2008, at 11:49 PM, Guido van Rossum wrote: >> >> Works for me. The other thing I always use from cgi is escape() -- >> will that be available somewhere else too? > > > xml.sax.saxutils.escape() would be an appropriate replacement,
though the
> location is a little funky.
More than a little IMO. :-(
Well, if that function is better than who cares about the location; it will end up in urllib.parse as some function.
It's a trivial function; it shouldn't pull in three packages and lots of other cruft.
So are you saying that it isn't that much better in urllib.parse? That only cuts the package count down by one.
I didn't mean to say, but it does seem the wrong module -- escape() is for HTML, not for URLs.
OK. I will only worry about moving cgi.parse_qs() to urllib.parse and cgi.escape() to the html package somewhere (either 'html', 'html.parser' which is currently HTMLParser, or some new module; I prefer the first option).
-Brett

On Sun, May 11, 2008 at 06:39:02PM -0700, Brett Cannon wrote:
cgi.escape() to the html package somewhere (either 'html', 'html.parser' which is currently HTMLParser, or some new module;
html.parser.escape() seems a bit backward; html.escape() fits the best!
Oleg.

On Sun, May 11, 2008 at 6:50 PM, Oleg Broytmann phd@phd.pp.ru wrote:
On Sun, May 11, 2008 at 06:39:02PM -0700, Brett Cannon wrote:
cgi.escape() to the html package somewhere (either 'html', 'html.parser' which is currently HTMLParser, or some new module;
html.parser.escape() seems a bit backward; html.escape() fits the best!
+1

On Sun, May 11, 2008 at 7:02 PM, Guido van Rossum guido@python.org wrote:
On Sun, May 11, 2008 at 6:50 PM, Oleg Broytmann phd@phd.pp.ru wrote:
On Sun, May 11, 2008 at 06:39:02PM -0700, Brett Cannon wrote:
cgi.escape() to the html package somewhere (either 'html', 'html.parser' which is currently HTMLParser, or some new module;
html.parser.escape() seems a bit backward; html.escape() fits the best!
+1
Issue 2829 is a bug report for copying cgi.parse_qs() to urllib.parse and 2830 for copying cgi.escape() to html.
-Brett

At 11:56 PM -0400 5/10/08, Fred Drake wrote:
On May 10, 2008, at 11:49 PM, Guido van Rossum wrote:
Works for me. The other thing I always use from cgi is escape() -- will that be available somewhere else too?
xml.sax.saxutils.escape() would be an appropriate replacement, though the location is a little funky.
At least it's right next to the valuable quoteattr().

Is there any thought to extending escape to escape / unescape to by default handle characters other than <, >, and &? At a minimum it should handle arbitrary &xxx; values. Ideally, it would also handle common other symbolic names besides < > etc.
HTML from common web sites such as nytimes.com frequently has a variety of characters escaped.
Consider the page at http://travel.nytimes.com/travel/guides/europe/france/provence-and-the-frenc...
It lists its content type as: content="text/html; charset=UTF-8" And contains text like: There’s the Côte d’ Ideally, we would decode ’ into ’ and ô into ô. Unfortunately, #146 is really an error -- it's not a utf-8 encoded unicode character but really a MS codepage 1252 character for apostrophe (apparently may HTML editing systems intermingle unicode and codepage 1252 content for apostrophes and a few other common characters). I'm happy to contribute some additional code for these other cases if people agree it's useful.
On May 12, 2008, at 10:36 AM, Tony Nelson wrote:
At 11:56 PM -0400 5/10/08, Fred Drake wrote:
On May 10, 2008, at 11:49 PM, Guido van Rossum wrote:
Works for me. The other thing I always use from cgi is escape() -- will that be available somewhere else too?
xml.sax.saxutils.escape() would be an appropriate replacement, though the location is a little funky.
At least it's right next to the valuable quoteattr().
TonyN.:' mailto:tonynelson@georgeanelson.com ' http://www.georgeanelson.com/ _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/thomaspinckney3%40gmail.co...

-Brett [from his iPod touch]
On 10-May-08, at 20:49, "Guido van Rossum" guido@python.org wrote:
Works for me. The other thing I always use from cgi is escape() -- will that be available somewhere else too?
It can be. =)
-Brett
On Sat, May 10, 2008 at 8:30 PM, Brett Cannon brett@python.org wrote:
I just realized that PEP 3108 was missing one proposal from the stdlib SIG (originally proposed by Facundo Batista) of copying the cgi.parse_qs() function over to the new urllib.parse module so that people no longer need to import the cgi module just for that one parsing function. Does anyone object if I update the PEP to include that change?
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (8)
-
Brett C.
-
Brett Cannon
-
Fred Drake
-
Georg Brandl
-
Guido van Rossum
-
Oleg Broytmann
-
Tom Pinckney
-
Tony Nelson