Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Victor Stinner <[email protected]>
  • Loading branch information
skirpichev and vstinner authored Aug 24, 2023
1 parent 048d8bf commit 058412e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Lib/test/test_module/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def test_module_setattr(self):
gsa.foo = 2
gsa.bar = 3
self.assertEqual(gsa.bar, 3)
del sys.modules['test.test_module.good_setattr']

def test_module_setattr_errors(self):
import test.test_module.bad_setattr as bsa
Expand All @@ -170,7 +171,8 @@ def test_module_setattr_errors(self):
with self.assertRaises(TypeError):
bad_setattr2.foo = 2
del sys.modules['test.test_module.bad_setattr']
del sys.modules['test.test_module.bad_setattr2']
if 'test.test_module.bad_setattr2' in sys.modules:
del sys.modules['test.test_module.bad_setattr2']

def test_module_delattr(self):
import test.test_module.good_delattr as gda
Expand All @@ -195,7 +197,8 @@ def test_module_delattr_errors(self):
with self.assertRaises(TypeError):
del bad_delattr2.foo
del sys.modules['test.test_module.bad_delattr']
del sys.modules['test.test_module.bad_delattr2']
if 'test.test_module.bad_delattr2' in sys.modules:
del sys.modules['test.test_module.bad_delattr2']

def test_module_dir(self):
import test.test_module.good_getattr as gga
Expand Down
3 changes: 2 additions & 1 deletion Objects/moduleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,8 @@ module_setattro(PyModuleObject *mod, PyObject *name, PyObject *value)
Py_DECREF(res);
return 0;
}
} else {
}
else {
PyObject *delattr;
if (PyDict_GetItemRef(mod->md_dict, &_Py_ID(__delattr__), &delattr) < 0) {
return -1;
Expand Down

0 comments on commit 058412e

Please sign in to comment.