#32272: gettext_lazy inconsistent error when nested --------------------------------------+------------------------------------ Reporter: John Bazik | Owner: nobody Type: Bug | Status: new Component: Internationalization | Version: 3.1 Severity: Normal | 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 Carlton Gibson):
* component: Utilities => Internationalization * stage: Unreviewed => Accepted Comment: I'll accept this, since there is a difference in behaviour. Given the code in `trans_null.py`, I'm not quite sure how the issue arrises: {{{ def gettext(message): return message gettext_noop = gettext_lazy = _ = gettext }}} Here `gettext_lazy` (and `_`) don't actually use `lazy`, so I'm not 100% sure how the equivalent line from the report comes up: {{{ gettext_lazy_noop = lazy(gettext_noop, str) }}} However, you've hit it in the wild, so I must presume it does 🤔 I wonder if forcing a string from `gettext()` in the the `trans_null` case makes sense? {{{ diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py index a687572b69..f590ff23cd 100644 --- a/django/utils/translation/trans_null.py +++ b/django/utils/translation/trans_null.py @@ -6,7 +6,7 @@ from django.conf import settings def gettext(message): - return message + return str(message) gettext_noop = gettext_lazy = _ = gettext }}} Resolves the reported issue but I don't know if it would have other consequences. -- Ticket URL: <https://code.djangoproject.com/ticket/32272#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.7b4bf753865a053f23ba5cc483629023%40djangoproject.com.