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

Refs #23919 -- Deprecated django.utils.http urllib equivalents #7906

Closed
wants to merge 2 commits into from

Conversation

claudep
Copy link
Member

@claudep claudep commented Jan 20, 2017

No description provided.

@claudep
Copy link
Member Author

claudep commented Jan 20, 2017

@timgraham I created that patch before the discussions about delaying deprecations for Python 2 stuff. So I can as well remove the deprecations if it is decided that way.

@claudep claudep force-pushed the utils_http branch 3 times, most recently from e49dc77 to 1861171 Compare January 26, 2017 13:54
@claudep
Copy link
Member Author

claudep commented Jan 26, 2017

One thing we are losing with removing our versions is to pass lazy URL strings to these functions. I'm not sure it's worth keeping them, as the use case is rather thin (AFAIK untested).
I've now split the commit in two parts, so the deprecation could be omitted.

Copy link
Member

@timgraham timgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, Aymeric proposed to start the deprecations in Django 2.2 or 3.0.

@@ -318,14 +318,14 @@ def urlencode(value, safe=None):
Escapes a value for use in a URL.

Takes an optional ``safe`` parameter used to determine the characters which
should not be escaped by Django's ``urlquote`` method. If not provided, the
should not be escaped by Python's ``quote`` method. If not provided, the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method -> function
Also, I usually use quote() rather than "quote" with backticks.

strings. The url is first UTF-8 encoded before quoting. The returned string
can safely be used as part of an argument to a subsequent iri_to_uri() call
without double-quoting occurring.
A legacy compatibility wrapper to Python's urllib.parse.quote() function.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might add something like "(did something different for Python 2)" similar to django.utils._os.

@@ -686,25 +686,18 @@ escaping HTML.

.. function:: urlquote(url, safe='/')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could remove the useless wrappers from the documentation.

Applying further encoding (such as :meth:`~django.utils.http.urlquote` or
``urllib.quote``) to the output of ``reverse()`` may produce undesirable
results.
Applying further encoding (such as :py:func:`urllib.parse.quote`) to the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the :py prefix isn't needed (at least, there are many more links without it than with it in Django's docs).

``iri_to_uri()`` call without double-quoting occurring. Employs lazy
execution.
A legacy compatibility wrapper to Python's
:py:func:`urllib.parse.quote_plus()` function.

.. function:: urlencode(query, doseq=0)

A version of Python's urllib.urlencode() function that can operate on
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here:

:func:`urllib.urlencode`

@claudep
Copy link
Member Author

claudep commented Jan 26, 2017

So far, Aymeric proposed to start the deprecations in Django 2.2 or 3.0.

How do you envision the process. List the to-deprecate stuff in a ticket or add a special warning in the code (which may be a noop until 2.2)?

@timgraham
Copy link
Member

timgraham commented Jan 26, 2017

Aymeric started a "Cleanups when no supported version of Django supports Python 2 anymore" ticket: #27753. I would add this deprecation there.

Copy link
Member

@timgraham timgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first commit looks good besides the outdated doc references flagged by the build error.

A version of Python's urllib.urlencode() function that can operate on
unicode strings. The parameters are first cast to UTF-8 encoded strings
and then encoded as per normal.
A version of Python's :func:`urllib.parse.urlencode()` function that can
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually the () are omitted since sphinx adds those to the rendered version.

@claudep
Copy link
Member Author

claudep commented Jan 26, 2017

I merged the first commit in fee42fd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants