[Django] #26621: simplify_regex having problems with named capture groups

66 views
Skip to first unread message

Django

unread,
May 16, 2016, 7:27:26 PM5/16/16
to django-...@googlegroups.com
#26621: simplify_regex having problems with named capture groups
-------------------------------+--------------------
Reporter: cancan101 | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
For example using the regex from [here](http://www.django-rest-
framework.org/api-guide/versioning/):


{{{
simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')

'/<version>)/bookings/<pk>/'
}}}

Escaping the `/` does not seem to help.

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

Django

unread,
May 19, 2016, 10:24:33 AM5/19/16
to django-...@googlegroups.com
#26621: simplify_regex having problems with named capture groups
-------------------------------+--------------------------------------

Reporter: cancan101 | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by akki):

* needs_better_patch: => 0
* version: 1.9 => master
* needs_tests: => 0
* needs_docs: => 0


Old description:

> For example using the regex from [here](http://www.django-rest-
> framework.org/api-guide/versioning/):
>

> {{{
> simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')
>
> '/<version>)/bookings/<pk>/'
> }}}
>
> Escaping the `/` does not seem to help.

New description:

For example using the regex from [http://www.django-rest-framework.org
/api-guide/versioning/ here]:


{{{
simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')

'/<version>/bookings/<pk>/'
}}}

Escaping the `/` does not seem to help.

--

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

Django

unread,
May 19, 2016, 10:42:11 AM5/19/16
to django-...@googlegroups.com
#26621: simplify_regex having problems with named capture groups
-------------------------------+--------------------------------------

Reporter: cancan101 | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Old description:

> For example using the regex from [http://www.django-rest-framework.org
> /api-guide/versioning/ here]:
>

> {{{
> simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')
>

> '/<version>/bookings/<pk>/'


> }}}
>
> Escaping the `/` does not seem to help.

New description:

For example using the regex from [http://www.django-rest-framework.org
/api-guide/versioning/ here]:


{{{
simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')

'/<version>/bookings/<pk>/'
}}}

Escaping the `/` does not seem to help.

EDIT: Somehow I pasted the wrong output. I come out as
`'/<version>)/bookings/<pk>/'` which is clearly broken.

--

Comment (by cancan101):

Somehow I pasted the wrong output. I come out as
`'/<version>)/bookings/<pk>/'`

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

Django

unread,
May 26, 2016, 2:42:15 PM5/26/16
to django-...@googlegroups.com
#26621: simplify_regex handles named capture groups incorrectly
-----------------------------------+------------------------------------
Reporter: cancan101 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admindocs | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* component: Uncategorized => contrib.admindocs


* needs_tests: => 0
* needs_docs: => 0

* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Old description:

> For example using the regex from [here](http://www.django-rest-
> framework.org/api-guide/versioning/):
>

> {{{
> simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')
>
> '/<version>)/bookings/<pk>/'
> }}}
>
> Escaping the `/` does not seem to help.

New description:

For example using a regex from [http://www.django-rest-framework.org/api-
guide/versioning/ Django Rest Framework docs]:

{{{
>>> from django.contrib.admindocs.views import simplify_regex


>>> simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')
'/<version>)/bookings/<pk>/'
}}}

The closing parenthesis in the output is unexpected.

Escaping the `/` does not seem to help.

--

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

Django

unread,
May 28, 2016, 1:44:36 AM5/28/16
to django-...@googlegroups.com
#26621: simplify_regex handles named capture groups incorrectly
-----------------------------------+--------------------------------------
Reporter: cancan101 | Owner: ketanbhatt
Type: Bug | Status: assigned

Component: contrib.admindocs | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by ketanbhatt):

* status: new => assigned
* owner: nobody => ketanbhatt


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

Django

unread,
May 28, 2016, 1:55:22 AM5/28/16
to django-...@googlegroups.com
#26621: simplify_regex handles named capture groups incorrectly
-----------------------------------+--------------------------------------
Reporter: cancan101 | Owner: ketanbhatt
Type: Bug | Status: assigned
Component: contrib.admindocs | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by ketanbhatt):

@cancan101
If you change your regex to
`^(?P<version>v1|v2)/bookings/(?P<pk>[0-9]+)/$` it will work as expected
(both the regex and `simplify_regex`).

But yes, `simplify_regex` needs to be fixed.

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

Django

unread,
May 30, 2016, 9:50:30 AM5/30/16
to django-...@googlegroups.com
#26621: simplify_regex handles named capture groups incorrectly
-----------------------------------+--------------------------------------
Reporter: cancan101 | Owner: ketanbhatt
Type: Bug | Status: assigned
Component: contrib.admindocs | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

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

In [changeset:"16a842b3795ca78a5918538ab6b9f1afbd718f72" 16a842b3]:
{{{
#!CommitTicketReference repository=""
revision="16a842b3795ca78a5918538ab6b9f1afbd718f72"
Refs #26621 -- Added tests for admindocs.views.simplify_regex().
}}}

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

Django

unread,
May 30, 2016, 10:02:54 AM5/30/16
to django-...@googlegroups.com
#26621: simplify_regex handles named capture groups incorrectly
-----------------------------------+--------------------------------------
Reporter: cancan101 | Owner: ketanbhatt
Type: Bug | Status: assigned
Component: contrib.admindocs | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/6660 PR] with comments for
improvement.

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

Django

unread,
Jul 17, 2016, 12:47:05 PM7/17/16
to django-...@googlegroups.com
#26621: simplify_regex handles named capture groups incorrectly
-----------------------------------+--------------------------------------
Reporter: cancan101 | Owner: ketanbhatt
Type: Bug | Status: assigned
Component: contrib.admindocs | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by timgraham):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26621#comment:6>

Django

unread,
Oct 5, 2016, 8:29:30 PM10/5/16
to django-...@googlegroups.com
#26621: simplify_regex handles named capture groups incorrectly
-----------------------------------+---------------------------------------
Reporter: Alex Rothberg | Owner: Ketan Bhatt

Type: Bug | Status: assigned
Component: contrib.admindocs | Version: 1.9
Severity: Normal | Resolution:
Keywords: | 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):

* needs_better_patch: 1 => 0

Django

unread,
Jan 3, 2017, 2:12:07 PM1/3/17
to django-...@googlegroups.com
#26621: simplify_regex handles named capture groups incorrectly
-----------------------------------+---------------------------------------
Reporter: Alex Rothberg | Owner: Ketan Bhatt
Type: Bug | Status: closed
Component: contrib.admindocs | Version: 1.9
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

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


Comment:

In [changeset:"f0ef0c49e9284f262fbc63e8a497699ca4a248fe" f0ef0c4]:
{{{
#!CommitTicketReference repository=""
revision="f0ef0c49e9284f262fbc63e8a497699ca4a248fe"
Fixed #26621 -- Corrected simplify_regex()'s handling of named capture
groups.
}}}

Reply all
Reply to author
Forward
0 new messages