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

Better documentation for the urlencode safe parameter #67229

Closed
wrwrwr mannequin opened this issue Dec 12, 2014 · 8 comments
Closed

Better documentation for the urlencode safe parameter #67229

wrwrwr mannequin opened this issue Dec 12, 2014 · 8 comments
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@wrwrwr
Copy link
Mannequin

wrwrwr mannequin commented Dec 12, 2014

BPO 23040
Nosy @bitdancer
Files
  • urlencode-safe.diff
  • urlencode-safe-v2.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 = None
    closed_at = <Date 2014-12-25.02:25:08.799>
    created_at = <Date 2014-12-12.15:34:59.690>
    labels = ['type-feature', 'docs']
    title = 'Better documentation for the urlencode safe parameter'
    updated_at = <Date 2014-12-25.02:25:08.774>
    user = 'https://bugs.python.org/wrwrwr'

    bugs.python.org fields:

    activity = <Date 2014-12-25.02:25:08.774>
    actor = 'r.david.murray'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2014-12-25.02:25:08.799>
    closer = 'r.david.murray'
    components = ['Documentation']
    creation = <Date 2014-12-12.15:34:59.690>
    creator = 'wrwrwr'
    dependencies = []
    files = ['37426', '37439']
    hgrepos = []
    issue_num = 23040
    keywords = ['patch']
    message_count = 8.0
    messages = ['232556', '232558', '232565', '232576', '232579', '232606', '233089', '233090']
    nosy_count = 4.0
    nosy_names = ['r.david.murray', 'docs@python', 'python-dev', 'wrwrwr']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23040'
    versions = ['Python 3.4', 'Python 3.5']

    @wrwrwr
    Copy link
    Mannequin Author

    wrwrwr mannequin commented Dec 12, 2014

    The documentation for urlencode() [1] isn't very clear on how the safe parameter is used, it would better not list it together with encoding and error as only applying to strings.

    [1] https://docs.python.org/3.5/library/urllib.parse.html#urllib.parse.urlencode

    @wrwrwr wrwrwr mannequin assigned docspython Dec 12, 2014
    @wrwrwr wrwrwr mannequin added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Dec 12, 2014
    @bitdancer
    Copy link
    Member

    The current documentation looks very clear to me, and I don't understand your changed version. Can you give an example of how the existing text is inaccurate or results in confusion?

    @wrwrwr
    Copy link
    Mannequin Author

    wrwrwr mannequin commented Dec 12, 2014

    I was looking at the sentence:
    "When query parameter is a str, the safe, encoding and error parameters are passed down to quote_plus() for encoding."

    The query argument can't be a string itself (gives a TypeError with 3.5a0 and I think it's only intended to accept dicts or sequences of 2-tuples). The "parameter" then must refer to a component of the query -- a key or a value.

    The safe argument is passed down and is effective no matter if a component is of str or bytes type (or a sequence with doseq), for example:

    >>> urlencode({b'/ n': ''}, safe='/')
    '/+n='
    (note the "b"; without "safe" the slash would get encoded as %2F).

    Maybe it would also be good to change "query parameter" to "query component" in that sentence.

    @bitdancer
    Copy link
    Member

    OK, now I understand. How about this phrasing:

    "The *safe*, *encoding*, and *error* parameters are passed down to :func:`quote_plus` (the *encoding* and *error* parameters are only passed when the query element is a :class:`str`).

    @wrwrwr
    Copy link
    Mannequin Author

    wrwrwr mannequin commented Dec 12, 2014

    Thanks, that's right and better, as it doesn't replicate the safe explanation.

    I've just noticed another small one, the docstring for quote() [2] says:
    "encoding must not be specified if string is a str" -- that should be "... is a bytes".

    [2] https://hg.python.org/cpython/file/default/Lib/urllib/parse.py#l690

    @wrwrwr
    Copy link
    Mannequin Author

    wrwrwr mannequin commented Dec 13, 2014

    Updated the patch, additionally changing "be" to "contain" in the first sentence.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 25, 2014

    New changeset 126aff7c6a33 by R David Murray in branch '3.4':
    bpo-23040: Clarify treatment of encoding and errors when component is bytes.
    https://hg.python.org/cpython/rev/126aff7c6a33

    New changeset 367ba031a743 by R David Murray in branch 'default':
    Merge: bpo-23040: Clarify treatment of encoding and errors when component is bytes.
    https://hg.python.org/cpython/rev/367ba031a743

    @bitdancer
    Copy link
    Member

    Thanks, Wojtek.

    @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
    docs Documentation in the Doc dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant