Skip to content

Commit

Permalink
fix expect interface for newer ptyprocess
Browse files Browse the repository at this point in the history
See #32147 for details
  • Loading branch information
dimpase committed Sep 26, 2023
1 parent 4d3e807 commit 69daf99
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/ptyprocess/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=ptyprocess-VERSION.tar.gz
sha1=3290062d67ef8a2f136bff9c2cd106673ff21316
md5=94e537122914cc9ec9c1eadcd36e73a1
cksum=1748633415
sha1=2d8830d1025c8e33149c7723c2f283122f9488c1
md5=9da200c397cb1752209a6b718b6cfc68
cksum=2094263560
upstream_url=https://pypi.io/packages/source/p/ptyprocess/ptyprocess-VERSION.tar.gz
4 changes: 1 addition & 3 deletions build/pkgs/ptyprocess/install-requires.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
ptyprocess ==0.5.1
# https://github.com/sagemath/sage/issues/31280#comment:42 and following
# sagelib is not compatible with ptyprocess 0.5.2, 0.6, and 0.7
ptyprocess > 0.5
2 changes: 1 addition & 1 deletion build/pkgs/ptyprocess/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.1.p0
0.7.0
3 changes: 2 additions & 1 deletion src/sage/interfaces/expect.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

import pexpect
from pexpect import ExceptionPexpect
from ptyprocess import PtyProcessError
import sage.interfaces.abc
from sage.interfaces.sagespawn import SageSpawn
from sage.interfaces.interface import (Interface, InterfaceElement,
Expand Down Expand Up @@ -561,7 +562,7 @@ def _close(self, force=True):
try:
if self._expect is not None:
self._expect.close(force=force)
except ExceptionPexpect:
except (PtyProcessError, ExceptionPexpect):
self._expect.ptyproc.fd = -1
self._expect.ptyproc.closed = True
self._expect.child_fd = -1
Expand Down
9 changes: 6 additions & 3 deletions src/sage/interfaces/sagespawn.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ AUTHOR:
# ***************************************************************************

from pexpect import *
from ptyprocess import PtyProcess
from ptyprocess import PtyProcess, PtyProcessError

from cpython.ref cimport Py_INCREF
from libc.signal cimport *
Expand Down Expand Up @@ -199,9 +199,12 @@ class SagePtyProcess(PtyProcess):
# but the default (UTF-8) will do now, since I don't
# think we have any non-ASCII quit_strings anyways.
self.write(str_to_bytes(self.quit_string))
except (OSError, IOError):
except (OSError, IOError, PtyProcessError):
pass
self.fileobj.close()
try:
self.fileobj.close()
except (OSError, IOError, PtyProcessError):
pass
self.fd = -1
self.closed = 1
self.terminate_async()
Expand Down

0 comments on commit 69daf99

Please sign in to comment.