[Django] #20222: Some functions are wrapped into allow_lazy incorrectly

11 views
Skip to first unread message

Django

unread,
Apr 8, 2013, 5:04:11 PM4/8/13
to django-...@googlegroups.com
#20222: Some functions are wrapped into allow_lazy incorrectly
----------------------------+--------------------
Reporter: void | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
allow_lazy() requires more than one argument. Second and further arguments
must be types.
There are a few functions which are wrapped into allow_lazy without
*resultclasses specified.
Namely:
* django.utils.html.strip_tags
* django.utils.text.Truncator.chars
* django.utils.text.Truncator.words
* django.utils.text.recapitalize
* django.utils.text.phone2numeric
* django.utils.text.unescape_string_literal

IPython session, which demonstrates code broken because of that:
{{{
In [1]: from django.utils.functional import lazy
In [2]: from django.utils.encoding import force_text
In [3]: from django.utils import six
In [4]: from django.utils.html import strip_tags
In [5]: promise = lazy(lambda:u'hello', six.text_type)()
In [6]: force_text(promise)
Out[6]: u'hello'
In [7]: promise = lazy(lambda:u'hello', six.text_type)()
In [8]: stripped = strip_tags(promise)
In [9]: force_text(stripped)
Out[9]: u'<django.utils.functional.__proxy__ object at 0x101f6ca50>'
}}}

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

Django

unread,
Apr 8, 2013, 5:30:09 PM4/8/13
to django-...@googlegroups.com
#20222: Some functions are wrapped into allow_lazy incorrectly
---------------------------+--------------------------------------

Reporter: void | Owner: nobody
Type: Bug | Status: new
Component: Utilities | 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 void):

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


Comment:

Thanks to bmispelon for pointing that out.

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

Django

unread,
Apr 9, 2013, 3:21:19 AM4/9/13
to django-...@googlegroups.com
#20222: Some functions are wrapped into allow_lazy incorrectly
---------------------------+------------------------------------

Reporter: void | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------+------------------------------------
Changes (by bmispelon):

* cc: bmispelon@… (added)
* easy: 0 => 1
* stage: Unreviewed => Accepted


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

Django

unread,
Apr 9, 2013, 9:18:11 AM4/9/13
to django-...@googlegroups.com
#20222: Some functions are wrapped into allow_lazy incorrectly
---------------------------+-------------------------------------
Reporter: void | Owner: bmispelon
Type: Bug | Status: assigned
Component: Utilities | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------+-------------------------------------
Changes (by bmispelon):

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


Comment:

I've started working on this on my branch:
https://github.com/bmispelon/django/compare/allow-lazy-refactor

I hope to fix #20221 and #20223 along with this one.

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

Django

unread,
Apr 10, 2013, 6:21:53 AM4/10/13
to django-...@googlegroups.com
#20222: Some functions are wrapped into allow_lazy incorrectly
---------------------------+-------------------------------------
Reporter: void | Owner: bmispelon
Type: Bug | Status: assigned
Component: Utilities | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------+-------------------------------------

Comment (by bmispelon):

I've prepared a pull request for this ticket that include fixes for 3
other ones: https://github.com/django/django/pull/1007

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

Django

unread,
Apr 29, 2013, 4:19:37 PM4/29/13
to django-...@googlegroups.com
#20222: Some functions are wrapped into allow_lazy incorrectly
---------------------------+-------------------------------------
Reporter: void | Owner: bmispelon
Type: Bug | Status: assigned
Component: Utilities | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* has_patch: 0 => 1


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

Django

unread,
Oct 9, 2013, 12:31:34 PM10/9/13
to django-...@googlegroups.com
#20222: Some functions are wrapped into allow_lazy incorrectly
---------------------------+-------------------------------------
Reporter: void | Owner: bmispelon
Type: Bug | Status: assigned
Component: Utilities | Version: master

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 timo):

* needs_better_patch: 0 => 1
* easy: 1 => 0


Comment:

No longer merges cleanly.

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

Django

unread,
Feb 24, 2015, 5:56:56 AM2/24/15
to django-...@googlegroups.com
#20222: Some functions are wrapped into allow_lazy incorrectly
---------------------------+-------------------------------------
Reporter: void | Owner: bmispelon
Type: Bug | Status: assigned
Component: Utilities | Version: master

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 void):

* needs_better_patch: 1 => 0


Comment:

I've updated bmispelon's patch so it merges cleanly as a pull request
4202:
https://github.com/django/django/pull/4202

--
Ticket URL: <https://code.djangoproject.com/ticket/20222#comment:7>

Django

unread,
Mar 16, 2015, 1:16:59 PM3/16/15
to django-...@googlegroups.com
#20222: Some functions are wrapped into allow_lazy incorrectly
---------------------------+-------------------------------------
Reporter: void | Owner: bmispelon
Type: Bug | Status: assigned
Component: Utilities | Version: master

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


Comment:

Comments for improvement on the PR.

--
Ticket URL: <https://code.djangoproject.com/ticket/20222#comment:8>

Django

unread,
Jan 22, 2016, 8:06:17 AM1/22/16
to django-...@googlegroups.com
#20222: Some functions are wrapped into allow_lazy incorrectly
---------------------------+-------------------------------------
Reporter: void | Owner: bmispelon
Type: Bug | Status: closed
Component: Utilities | Version: master
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 timgraham):

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


Comment:

Correct me if I'm wrong, but based on the sample shell session, I think
this is fixed by #25000.

--
Ticket URL: <https://code.djangoproject.com/ticket/20222#comment:9>

Reply all
Reply to author
Forward
0 new messages