Opened 10 years ago

Closed 8 years ago

#24781 closed Bug (fixed)

lazy() may need a __repr__ for Python 2

Reported by: jdh13 Owned by: Chesco Igual
Component: Utilities Version: 1.7
Severity: Normal Keywords: py2
Cc: Chesco Igual Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Baptiste Mispelon)

in python2:

>>> from django.apps import apps
>>> apps.get_app_config('admin').verbose_name

displays:

<django.utils.functional.__proxy__ object at 0x2c24c10>

instead of name

Change History (11)

comment:1 by Baptiste Mispelon, 10 years ago

Component: UncategorizedDocumentation
Description: modified (diff)
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

(the doc is here: https://docs.djangoproject.com/en/dev/ref/applications/)

Interestingly, doing print(apps.get_app_config('admin').verbose_name) still gives a useless repr on python2 under 1.7.
On master or on Python 3, you get the expected behavior ("admin" is printed, or a translation in your active language).

comment:2 by Baptiste Mispelon, 10 years ago

For what it's worth (I'm not sure if there's an actual bug to be fixed here), I bisected the print issue to ea3e40c278eb27fb3c8362d9e8cd67f957bf4f57.

comment:3 by Tim Graham, 9 years ago

I think the root cause is related to #25000 (I could reproduce the issue on master with Python 2). Adding a __repr__() method similar to the __str__() method added in the linked ticket seems to fix the issue:

def __repr__(self):
    return repr(self.__cast())

Not entirely sure that's the proper solution.

comment:4 by Tim Graham, 9 years ago

Component: DocumentationUtilities
Keywords: python2 added
Summary: incorrect command in doc: Applicationslazy() may need a __repr__ for Python 2

comment:5 by Tim Graham, 8 years ago

Keywords: py2 added; python2 removed

comment:6 by Carl Meyer, 8 years ago

Easy pickings: set

comment:7 by Philip James, 8 years ago

Owner: changed from nobody to Philip James
Status: newassigned

comment:8 by Chesco Igual, 8 years ago

Owner: changed from Philip James to Chesco Igual

comment:9 by Chesco Igual, 8 years ago

Cc: Chesco Igual added
Has patch: set

comment:10 by Carl Meyer, 8 years ago

Triage Stage: AcceptedReady for checkin

comment:11 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In ffd1873:

Fixed #24781 -- Fixed repr() for lazy objects.

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