Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24220 closed Bug (fixed)

get_success_url raises an exception when success_url is lazy object

Reported by: Tomáš Ehrlich Owned by: Tomáš Ehrlich
Component: Generic views Version: 1.8alpha1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Change History (4)

comment:1 by Tomáš Ehrlich, 9 years ago

Has patch: set
Owner: changed from nobody to Tomáš Ehrlich
Status: newassigned

comment:2 by Tomáš Ehrlich, 9 years ago

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

comment:3 by Tomáš Ehrlich <tomas.ehrlich@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 511be35779a98427387d9aa4abacce01dedd7272:

Fixed #24220 - Allowed lazy objects for success_url

comment:4 by Tim Graham <timograham@…>, 9 years ago

In 5dff3513cc1bb998abe60f52269790268a74220c:

[1.8.x] Fixed #24220 - Allowed lazy objects for success_url

Backport of 511be35779a98427387d9aa4abacce01dedd7272 from master

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