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

relocate cgi.parse_qs() into urlparse #37091

dyoo mannequin opened this issue Aug 26, 2002 · 14 comments

relocate cgi.parse_qs() into urlparse #37091

dyoo mannequin opened this issue Aug 26, 2002 · 14 comments
type-feature A feature request or enhancement


Copy link

dyoo mannequin commented Aug 26, 2002

BPO 600362
Nosy @brettcannon, @facundobatista, @orsenthil, @hdiogenes
  • issue600362-py26-v3.diff
  • issue600362-py3k-v3.diff
  • 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 = ''
    closed_at = <Date 2008-09-03.22:52:24.529>
    created_at = <Date 2002-08-26.18:24:42.000>
    labels = ['type-feature']
    title = 'relocate cgi.parse_qs() into urlparse'
    updated_at = <Date 2008-09-03.22:52:24.528>
    user = '' fields:

    activity = <Date 2008-09-03.22:52:24.528>
    actor = 'facundobatista'
    assignee = 'facundobatista'
    closed = True
    closed_date = <Date 2008-09-03.22:52:24.529>
    closer = 'facundobatista'
    components = ['None']
    creation = <Date 2002-08-26.18:24:42.000>
    creator = 'dyoo'
    dependencies = []
    files = ['11356', '11357']
    hgrepos = []
    issue_num = 600362
    keywords = ['patch']
    message_count = 14.0
    messages = ['61094', '61095', '61868', '67601', '68551', '68557', '68946', '69099', '71151', '71214', '71915', '72284', '72387', '72430']
    nosy_count = 7.0
    nosy_names = ['brett.cannon', 'facundobatista', 'dyoo', 'orsenthil', 'draghuram', 'hdiogenes', 'mgiuca']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = ''
    versions = ['Python 2.6', 'Python 3.0']

    Copy link
    Mannequin Author

    dyoo mannequin commented Aug 26, 2002

    The location of the url-handling functions are
    distributed among several modules, and it would be good
    to consolidate them to make them easier to find.

    The urlparse.urlparse() function splits an url into its
    relative pieces. However, it does not parse out the
    query string into a dictionary --- that role is played
    by cgi.parse_qs(). And to convert a dictionary back to
    a query string, the programmer needs to know that that
    function is in urllib.urlencode.

    It would be nice to have cgi.parse_qs() and
    urllib.urlencode() in a unified place, within in the
    urlparse module if appropriate. This will help reduce
    the amount of hunting-and-pecking that beginners do
    when they're trying to deal with URLs.


    for more information.


    @dyoo dyoo mannequin added the type-feature A feature request or enhancement label Aug 26, 2002
    Copy link

    Logged In: YES

    This is a problem. Should a wrapper in urlparse for cgi.parse_qs but created
    or should it just be documented that to parse a query string you should use

    Copy link

    draghuram mannequin commented Jan 30, 2008

    I know that Senthil has been working on consolidating url related
    functionalities so I am adding him to the list.

    Copy link

    parse_qs and parse_qsl moved to urlparse with this patch.
    I dont think urlencode would be a good method for urlparse. But this
    will cease to exist with the addressing of 3108.

    Copy link

    hdiogenes mannequin commented Jun 21, 2008

    The patch is not applying cleanly.

    BTW, urlparse has been renamed to urllib.parse, but the old docs are still
    there (urlparse.rst).

    Copy link

    hdiogenes mannequin commented Jun 22, 2008

    Correction: the patch does apply cleanly to 2.6, without breaking tests.
    It just needs to be ported to 3.0 (new urllib package).

    Copy link

    • Updated patches for Python 2.6 and Python 3.0
    • Moved the tests.
    • Updated docs.

    Somebody please review this so that it can checked in.

    Copy link

    Hi Senthil, some details:

    • You should not withdraw the parse_qsl from cgi.rst (btw, why didn't
      you extracted also the parse_qs one?), but put a Deprecation message,
      saying that the user should use it from the urlparse module.

    • In, in the added message "parse query string functions called
      from urlparse", you should say that this is for backward compatibility

    • You defined an "unquote" function in Isn't this function
      the same that already exists in urllib? Why can't you just use that one?

    Thank you!!

    @facundobatista facundobatista self-assigned this Jul 2, 2008
    Copy link

    Hi Facundo,
    This issue/comments somehow escaped from my noticed, initially. I have
    addressed your comments in the new set of patches.

    1. Previous patch Docs had issues. Updated the Docs patch.
    2. Included message in about parse_qs, parse_qsl being present
      for backward compatiblity.
    3. The reason, py26 version of patch has quote function from urllib is
      to avoid circular reference. urllib import urlparse for urljoin method.
      So only way for us use quote is to have that portion of code in the
      patch as well.

    Please have a look the patches.
    As this request has been present from a long time ( 2002-08-26 !), is it
    possible to include this change in b3?


    Copy link

    This is ok, maybe with some small changes in the docs.

    I asked in python-dev if this should go now or wait until 2.7/3.1

    Copy link

    mgiuca mannequin commented Aug 25, 2008

    It seems like parse_multipart and parse_header are very strongly related
    to parse_qs. (eg. if you want to process HTTP requests you'll want to
    call parse_qs for x-www-form-urlencoded and parse_multipart for

    Should these be moved too? (They aren't part of the url syntax though,
    so it doesn't make sense for them to be in urlparse).

    Copy link

    Senthil, please update the patchs, adding a DeprecationWarning in 3.0 and
    a PendingDeprecationWarning in 2.6.


    Copy link

    Facundo, I have updated the patch against the trunk. Added the
    PendingDeprecationWarning for py26 and DeprecationWarning for py3k.
    All tests pass ok. Please verify and plan to apply this patch before rc1.

    Copy link

    Commited in r66196 and r66199, this went into 2.6/3.0 rc1!!

    Thank you all for the effort!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    type-feature A feature request or enhancement
    None yet

    No branches or pull requests

    3 participants