Opened 8 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#28663 closed New feature (fixed)

Check for likely incorrectly migrated django.urls.path() calls (that still have regex characters in the route)

Reported by: Chris Lamb Owned by: nobody
Component: Core (URLs) Version: 2.0
Severity: Normal Keywords: check urls
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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:

    from django.conf.urls import url

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

to

    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...)

Change History (5)

comment:1 Changed 8 weeks ago by Chris Lamb

Has patch: set

comment:2 Changed 8 weeks ago by Chris Lamb

PR updated after review.

comment:3 Changed 7 weeks ago by Tim Graham

Summary: Check for incorrectly migrated django.urls.path callsCheck for likely incorrectly migrated django.urls.path() calls (that still have regex characters in the route)
Triage Stage: UnreviewedAccepted

comment:4 Changed 2 weeks ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 998c9dd:

Fixed #28663 -- Add a check for likely incorrectly migrated django.urls.path() routes.

comment:5 Changed 2 weeks ago by Tim Graham <timograham@…>

In 518c1135:

[2.0.x] Fixed #28663 -- Add a check for likely incorrectly migrated django.urls.path() routes.

Backport of 998c9dd599cd907bb38f440fff13a808571589f8 from master

Note: See TracTickets for help on using tickets.
Back to Top