Skip to content

Commit a500f43

Browse files
authored
Resolve new flake8 error (#4462)
* Resolve flake8 error by replacing `pytest.raises(Exception)` with `SystemError` * Also remove the obsolete comment. * Tweak comment instead of removing it.
1 parent c709d2a commit a500f43

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tests/test_modules.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,10 @@ def test_def_submodule_failures():
107107
sm_name_orig = sm.__name__
108108
sm.__name__ = malformed_utf8
109109
try:
110-
with pytest.raises(Exception):
111-
# Seen with Python 3.9: SystemError: nameless module
112-
# But we do not want to exercise the internals of PyModule_GetName(), which could
113-
# change in future versions of Python, but a bad __name__ is very likely to cause
114-
# some kind of failure indefinitely.
110+
# We want to assert that a bad __name__ causes some kind of failure, although we do not want to exercise
111+
# the internals of PyModule_GetName(). Currently all supported Python versions raise SystemError. If that
112+
# changes in future Python versions, simply add the new expected exception types here.
113+
with pytest.raises(SystemError):
115114
m.def_submodule(sm, b"SubSubModuleName")
116115
finally:
117116
# Clean up to ensure nothing gets upset by a module with an invalid __name__.

0 commit comments

Comments
 (0)