[Django] #24220: get_success_url raises an exception when success_url is lazy object

19 views
Skip to first unread message

Django

unread,
Jan 26, 2015, 4:18:58 AM1/26/15
to django-...@googlegroups.com
#24220: get_success_url raises an exception when success_url is lazy object
-------------------------------+-----------------------
Reporter: tricoder42 | Owner: nobody
Type: Bug | Status: new
Component: Generic views | Version: 1.8alpha1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------
In #24133 was added deprecation warning when `self.success_url` contains
old %-style Python formatting strings.

However, `success_url` could be a lazy object like `reverse_lazy` and
trying to call `re.search` on lazy object results in `TypeError`:


{{{
../../../../.envs/lingui-next/lib/python3.4/site-
packages/django/views/generic/edit.py:166: in get_success_url
if re.search(r'%\([^\)]+\)', self.success_url):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _

pattern = '%\\([^\\)]+\\)'
string = <django.utils.functional.lazy.<locals>.__proxy__ object at
0x10678ca90>
flags = 0

def search(pattern, string, flags=0):
"""Scan through string looking for a match to the pattern,
returning
a match object, or None if no match was found."""
> return _compile(pattern, flags).search(string)
E TypeError: expected string or buffer

../../../../.envs/lingui-next/lib/python3.4/re.py:166: TypeError
}}}

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

Django

unread,
Jan 26, 2015, 5:16:49 AM1/26/15
to django-...@googlegroups.com
#24220: get_success_url raises an exception when success_url is lazy object
-------------------------------+--------------------------------------
Reporter: tricoder42 | Owner: tricoder42
Type: Bug | Status: assigned

Component: Generic views | Version: 1.8alpha1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* status: new => assigned
* needs_better_patch: => 0
* needs_tests: => 0
* owner: nobody => tricoder42
* needs_docs: => 0
* has_patch: 0 => 1


Comment:

Added PR https://github.com/django/django/pull/3989

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

Django

unread,
Jan 26, 2015, 5:21:59 AM1/26/15
to django-...@googlegroups.com
#24220: get_success_url raises an exception when success_url is lazy object
-------------------------------+--------------------------------------
Reporter: tricoder42 | Owner: tricoder42
Type: Bug | Status: assigned
Component: Generic views | Version: 1.8alpha1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

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

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

Comment (by tricoder42):

Also please look at #24221 which is a small optimization of #24133

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

Django

unread,
Jan 26, 2015, 12:42:10 PM1/26/15
to django-...@googlegroups.com
#24220: get_success_url raises an exception when success_url is lazy object
-------------------------------+--------------------------------------
Reporter: tricoder42 | Owner: tricoder42
Type: Bug | Status: closed

Component: Generic views | Version: 1.8alpha1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Unreviewed

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

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Tomáš Ehrlich <tomas.ehrlich@…>):

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


Comment:

In [changeset:"511be35779a98427387d9aa4abacce01dedd7272"]:
{{{
#!CommitTicketReference repository=""
revision="511be35779a98427387d9aa4abacce01dedd7272"
Fixed #24220 - Allowed lazy objects for success_url
}}}

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

Django

unread,
Jan 26, 2015, 12:42:22 PM1/26/15
to django-...@googlegroups.com
#24220: get_success_url raises an exception when success_url is lazy object
-------------------------------+--------------------------------------
Reporter: tricoder42 | Owner: tricoder42
Type: Bug | Status: closed
Component: Generic views | Version: 1.8alpha1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Unreviewed

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:"5dff3513cc1bb998abe60f52269790268a74220c"]:
{{{
#!CommitTicketReference repository=""
revision="5dff3513cc1bb998abe60f52269790268a74220c"
[1.8.x] Fixed #24220 - Allowed lazy objects for success_url

Backport of 511be35779a98427387d9aa4abacce01dedd7272 from master
}}}

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

Reply all
Reply to author
Forward
0 new messages