﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29467	override_settings context manager can leave undesired settings state	Sławek Ehlert	Sławek Ehlert	"When connecting to the {{{setting_changed}}} signal a receiver function that throws an error, one can break the {{{override_settings}}} decorator/context manager and leave the current settings in the modified state. {{{override_settings}}} context manager should be more defensive inside the ""enter"" part when the {{{setting_changed}}} signal is sent. 

Example:
{{{
## settings
SETTING_A = 'A'
SETTING_B = 'B'

## usage
from django.test import override_settings
from django.conf import settings
from django.core import signals


def setting_changed_receiver(*args, **kwargs):
    if kwargs['setting'] == 'SETTING_B':
        raise Exception(""I'm here for the lulz"")


signals.setting_changed.connect(setting_changed_receiver)

try:
    with override_settings(SETTING_A='X', SETTING_B='X'):
        pass
except:
    pass

print(settings.SETTING_A)
print(settings.SETTING_B)

}}}

prints out:
{{{
X
X
}}}

instead of the expected:
{{{
A
B
}}}

This may have some repercussions while running tests, since one failing test can influence a different, unrelated one. "	Bug	closed	Testing framework	2.0	Normal	fixed	settings override_settings	Mariusz Felisiak Carlton Gibson	Accepted	1	0	0	0	0	0
