diff options
author | Matti Picus <matti.picus@gmail.com> | 2022-02-03 17:57:58 +0200 |
---|---|---|
committer | Matti Picus <matti.picus@gmail.com> | 2022-02-03 17:57:58 +0200 |
commit | 566d7863ce7f0b7a2f24546f649a86e185ebbf8b (patch) | |
tree | 24630f6a7f161ba8c854d591728d1c92cf492061 | |
parent | fix order of args to W_PyCMethodObject.__init__ (diff) | |
download | pypy-566d7863ce7f0b7a2f24546f649a86e185ebbf8b.tar.gz pypy-566d7863ce7f0b7a2f24546f649a86e185ebbf8b.tar.bz2 pypy-566d7863ce7f0b7a2f24546f649a86e185ebbf8b.zip |
add missing check to PyState_AddModule
-rw-r--r-- | pypy/module/cpyext/pystate.py | 3 | ||||
-rw-r--r-- | pypy/module/cpyext/test/test_module.py | 4 | ||||
-rw-r--r-- | pypy/tool/pytest/apptest.py | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/pypy/module/cpyext/pystate.py b/pypy/module/cpyext/pystate.py index 3167387c64..91506050cf 100644 --- a/pypy/module/cpyext/pystate.py +++ b/pypy/module/cpyext/pystate.py @@ -397,6 +397,9 @@ def PyState_AddModule(space, w_module, moddef): interp.c_modules_by_index = make_ref(space, w_by_index) else: w_by_index = from_ref(space, interp.c_modules_by_index) + if moddef.c_m_slots: + raise oefmt(space.w_SystemError, + "PyState_AddModule called on module with slots"); if index < space.len_w(w_by_index): w_module_seen = space.getitem(w_by_index, space.newint(index)) if space.eq_w(w_module_seen, w_module): diff --git a/pypy/module/cpyext/test/test_module.py b/pypy/module/cpyext/test/test_module.py index f74709404d..20732436b3 100644 --- a/pypy/module/cpyext/test/test_module.py +++ b/pypy/module/cpyext/test/test_module.py @@ -253,9 +253,9 @@ class AppTestMultiPhase2(AppTestCpythonExtensionBase): def test_try_registration(self): module = self.import_module(name=self.name, use_imp=True) assert module.call_state_registration_func(0) is None - with pytest.raises(SystemError): + with raises(SystemError): module.call_state_registration_func(1) - with pytest.raises(SystemError): + with raises(SystemError): module.call_state_registration_func(2) def w_load_from_name(self, name, origin=None, use_prefix=True): diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py index 566260da50..a598c59af4 100644 --- a/pypy/tool/pytest/apptest.py +++ b/pypy/tool/pytest/apptest.py @@ -140,7 +140,7 @@ if 1: def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: - pytest.fail("DID NOT RAISE") + raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) |