[Django] #28663: Check for incorrectly migrated django.urls.path calls

10 views
Skip to first unread message

Django

unread,
Oct 1, 2017, 4:17:40 AM10/1/17
to django-...@googlegroups.com
#28663: Check for incorrectly migrated django.urls.path calls
---------------------------------------+----------------------------
Reporter: Chris Lamb | Owner: nobody
Type: New feature | Status: new
Component: Core (URLs) | Version: 2.0
Severity: Normal | Keywords: check urls
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+----------------------------
I recently moved a project to Django 2.x, including moving to
``django.urls.path``. However, I wasn't careful enough in the details so
ended up migrating, for example:

{{{#!python
from django.conf.urls import url

url('^faq$', views.faq,
name='faq'),
}}}

to

{{{#!python
from django.urls import path

path('^faq$', views.faq,
name='faq'),
}}}

This doesn't cause any errors (!) but results in, for example,
{{{reverse('faq')}}} returning the (encoded) url {{{/%5Efaq$}}}.

As this is a) likely to be very common during the migration with a high
cost of a true positive, combined with b) the fact that the chance of a
false positive is fairly low, I suggest we add a check for this.

(PR incoming...)

--
Ticket URL: <https://code.djangoproject.com/ticket/28663>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 1, 2017, 4:20:21 AM10/1/17
to django-...@googlegroups.com
#28663: Check for incorrectly migrated django.urls.path calls
-----------------------------+--------------------------------------

Reporter: Chris Lamb | Owner: nobody
Type: New feature | Status: new
Component: Core (URLs) | Version: 2.0
Severity: Normal | Resolution:

Keywords: check urls | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by Chris Lamb):

* has_patch: 0 => 1


Comment:

PR with tests: https://github.com/django/django/pull/9183

--
Ticket URL: <https://code.djangoproject.com/ticket/28663#comment:1>

Django

unread,
Oct 2, 2017, 4:20:46 AM10/2/17
to django-...@googlegroups.com
#28663: Check for incorrectly migrated django.urls.path calls
-----------------------------+--------------------------------------

Reporter: Chris Lamb | Owner: nobody
Type: New feature | Status: new
Component: Core (URLs) | Version: 2.0
Severity: Normal | Resolution:

Keywords: check urls | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------

Comment (by Chris Lamb):

PR updated after review.

--
Ticket URL: <https://code.djangoproject.com/ticket/28663#comment:2>

Django

unread,
Oct 6, 2017, 11:10:18 AM10/6/17
to django-...@googlegroups.com
#28663: Check for likely incorrectly migrated django.urls.path() calls (that still
have regex characters in the route)
-----------------------------+------------------------------------

Reporter: Chris Lamb | Owner: nobody
Type: New feature | Status: new
Component: Core (URLs) | Version: 2.0
Severity: Normal | Resolution:
Keywords: check urls | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28663#comment:3>

Django

unread,
Nov 7, 2017, 11:40:18 AM11/7/17
to django-...@googlegroups.com
#28663: Check for likely incorrectly migrated django.urls.path() calls (that still
have regex characters in the route)
-----------------------------+------------------------------------
Reporter: Chris Lamb | Owner: nobody
Type: New feature | Status: closed

Component: Core (URLs) | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: check urls | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"998c9dd599cd907bb38f440fff13a808571589f8" 998c9dd]:
{{{
#!CommitTicketReference repository=""
revision="998c9dd599cd907bb38f440fff13a808571589f8"
Fixed #28663 -- Add a check for likely incorrectly migrated
django.urls.path() routes.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28663#comment:4>

Django

unread,
Nov 7, 2017, 1:06:02 PM11/7/17
to django-...@googlegroups.com
#28663: Check for likely incorrectly migrated django.urls.path() calls (that still
have regex characters in the route)
-----------------------------+------------------------------------
Reporter: Chris Lamb | Owner: nobody
Type: New feature | Status: closed

Component: Core (URLs) | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: check urls | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"518c11352c3adad20b8d4a255369d2b8bd6f61fb" 518c1135]:
{{{
#!CommitTicketReference repository=""
revision="518c11352c3adad20b8d4a255369d2b8bd6f61fb"
[2.0.x] Fixed #28663 -- Add a check for likely incorrectly migrated
django.urls.path() routes.

Backport of 998c9dd599cd907bb38f440fff13a808571589f8 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28663#comment:5>

Reply all
Reply to author
Forward
0 new messages