diff --git a/changelog/7913.bugfix.rst b/changelog/7913.bugfix.rst new file mode 100644 index 000000000..e8c4613bf --- /dev/null +++ b/changelog/7913.bugfix.rst @@ -0,0 +1 @@ +Fixed a crash or hang in ``pytester.spawn`` when the ``readline`` module is involved. diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index a1768363b..935be84c1 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -707,8 +707,11 @@ class Pytester: # Some zope modules used by twisted-related tests keep internal state # and can't be deleted; we had some trouble in the past with # `zope.interface` for example. + # + # Preserve readline due to https://bugs.python.org/issue41033. + # pexpect issues a SIGWINCH. def preserve_module(name): - return name.startswith("zope") + return name.startswith(("zope", "readline")) return SysModulesSnapshot(preserve=preserve_module)