Opened 9 years ago

Last modified 9 years ago

#25295 closed Bug

override context manager does not return to deactivated state — at Initial Version

Reported by: David Nelson Adamec Owned by: nobody
Component: Internationalization Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

From a shell, I'm able to do the following:

In [1]: from django.utils import translation

In [2]: translation.get_language()

In [3]: with translation.override('fr'):

...: pass
...:

In [4]: translation.get_language()
Out[4]: 'fr'

override usually reverts to the previous language upon leaving the context manager, so this behavior seems unexpected.

This is new in Django 1.8: before, get_language() returned the default language, so the default language would be activated after override finished. Now get_language() returns None when there is no active catalog, so override attempts to activate None, which has no effect.

Change History (0)

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