[Django] #30280: _get_FIELD_display returns proxies in 2.2rc1 but always returned strings previously

15 views
Skip to first unread message

Django

unread,
Mar 22, 2019, 7:16:26 AM3/22/19
to django-...@googlegroups.com
#30280: _get_FIELD_display returns proxies in 2.2rc1 but always returned strings
previously
-------------------------------------+-------------------------------------
Reporter: Matthias | Owner: nobody
Kestenholz |
Type: Bug | Status: new
Component: Database | Version: 2.2
layer (models, ORM) |
Severity: Release | Keywords:
blocker |
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I'm not sure whether that was wanted but
https://github.com/django/django/commit/cc79c7ee637e65c8da27e56d746c87903d5ec901
(see https://code.djangoproject.com/ticket/27795 ) introduced a change
where code which calls `get_*_display` got a string previously and now
gets a proxy under some circumstances.

If this isn't wanted (and I cannot find anything in the release notes
saying that it is) then that's a regression which should be fixed before
releasing Django 2.2.

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

Django

unread,
Mar 22, 2019, 7:20:14 AM3/22/19
to django-...@googlegroups.com
#30280: _get_FIELD_display returns proxies in 2.2rc1 but always returned strings
previously
-------------------------------------+-------------------------------------
Reporter: Matthias Kestenholz | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Matthias Kestenholz):

... thinking about this some more, maybe it makes sense to return lazy
strings when using lazy strings inside `choices`.

If that's the case this would certainly warrant a mention in the release
notes (or maybe I haven't found it?)

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

Django

unread,
Mar 22, 2019, 8:08:18 AM3/22/19
to django-...@googlegroups.com
#30280: Model_get_FIELD_display() returns proxies in 2.2rc1 but always returned
strings previously
-------------------------------------+-------------------------------------
Reporter: Matthias Kestenholz | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | 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 Tim Graham):

* stage: Unreviewed => Accepted


Old description:

> I'm not sure whether that was wanted but
> https://github.com/django/django/commit/cc79c7ee637e65c8da27e56d746c87903d5ec901
> (see https://code.djangoproject.com/ticket/27795 ) introduced a change
> where code which calls `get_*_display` got a string previously and now
> gets a proxy under some circumstances.
>
> If this isn't wanted (and I cannot find anything in the release notes
> saying that it is) then that's a regression which should be fixed before
> releasing Django 2.2.

New description:

I'm not sure whether that was wanted but

cc79c7ee637e65c8da27e56d746c87903d5ec901 (#27795) introduced a change


where code which calls `get_*_display` got a string previously and now
gets a proxy under some circumstances.

If this isn't wanted (and I cannot find anything in the release notes
saying that it is) then that's a regression which should be fixed before
releasing Django 2.2.

--

Comment:

Probably `str()` could be used where `force_text()` was used previously.
By the way, you should explain how to reproduce the issue, i.e. what
"under some circumstances" means.

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

Django

unread,
Mar 22, 2019, 8:26:04 AM3/22/19
to django-...@googlegroups.com
#30280: Model_get_FIELD_display() returns proxies in 2.2rc1 but always returned
strings previously
-------------------------------------+-------------------------------------
Reporter: Matthias Kestenholz | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | 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 Matthias Kestenholz):

You're right, thanks. I could have explained it better.

[https://github.com/django/django/pull/11109 PR]

The code which failed was:

{{{
class Project(Model):
ACQUISITION = "acquisition"

TYPE_CHOICES = [
(ACQUISITION, _("Acquisition")),
...
]

type = models.CharField(_("type"), choices=TYPE_CHOICES,
max_length=20)
closed_on = models.DateField(_("closed on"), blank=True, null=True)

def pretty_status(self):
parts = [self.get_type_display()]
if self.closed_on:
parts.append(
gettext("closed on %s") %
local_date_format(self.closed_on, "d.m.Y")
)
return ", ".join(parts)
}}}

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

Django

unread,
Mar 22, 2019, 1:02:07 PM3/22/19
to django-...@googlegroups.com
#30280: Model_get_FIELD_display() returns proxies in 2.2rc1 but always returned
strings previously
-------------------------------------+-------------------------------------

Reporter: Matthias Kestenholz | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution: fixed
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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"ea071870f943c23a8eaf36dfcdf382afd6478fd1" ea071870]:
{{{
#!CommitTicketReference repository=""
revision="ea071870f943c23a8eaf36dfcdf382afd6478fd1"
Fixed #30280 -- Restored Model.get_FIELD_display()'s coercion of lazy
strings.

Reverted cc79c7ee637e65c8da27e56d746c87903d5ec901.
}}}

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

Django

unread,
Mar 22, 2019, 1:15:55 PM3/22/19
to django-...@googlegroups.com
#30280: Model_get_FIELD_display() returns proxies in 2.2rc1 but always returned
strings previously
-------------------------------------+-------------------------------------

Reporter: Matthias Kestenholz | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution: fixed
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:"a86ffb3e0fd8a37ff1b9affc177e81ef9298ec36" a86ffb3e]:
{{{
#!CommitTicketReference repository=""
revision="a86ffb3e0fd8a37ff1b9affc177e81ef9298ec36"
[2.2.x] Fixed #30280 -- Restored Model.get_FIELD_display()'s coercion of
lazy strings.

Reverted cc79c7ee637e65c8da27e56d746c87903d5ec901.

Backport of ea071870f943c23a8eaf36dfcdf382afd6478fd1 from master.
}}}

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

Reply all
Reply to author
Forward
0 new messages