Skip to content

Commit 69daf99

Browse files
committed
fix expect interface for newer ptyprocess
See #32147 for details
1 parent 4d3e807 commit 69daf99

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tarball=ptyprocess-VERSION.tar.gz
2-
sha1=3290062d67ef8a2f136bff9c2cd106673ff21316
3-
md5=94e537122914cc9ec9c1eadcd36e73a1
4-
cksum=1748633415
2+
sha1=2d8830d1025c8e33149c7723c2f283122f9488c1
3+
md5=9da200c397cb1752209a6b718b6cfc68
4+
cksum=2094263560
55
upstream_url=https://pypi.io/packages/source/p/ptyprocess/ptyprocess-VERSION.tar.gz
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
ptyprocess ==0.5.1
2-
# https://github.com/sagemath/sage/issues/31280#comment:42 and following
3-
# sagelib is not compatible with ptyprocess 0.5.2, 0.6, and 0.7
1+
ptyprocess > 0.5
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.1.p0
1+
0.7.0

src/sage/interfaces/expect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
import pexpect
5252
from pexpect import ExceptionPexpect
53+
from ptyprocess import PtyProcessError
5354
import sage.interfaces.abc
5455
from sage.interfaces.sagespawn import SageSpawn
5556
from sage.interfaces.interface import (Interface, InterfaceElement,
@@ -561,7 +562,7 @@ def _close(self, force=True):
561562
try:
562563
if self._expect is not None:
563564
self._expect.close(force=force)
564-
except ExceptionPexpect:
565+
except (PtyProcessError, ExceptionPexpect):
565566
self._expect.ptyproc.fd = -1
566567
self._expect.ptyproc.closed = True
567568
self._expect.child_fd = -1

src/sage/interfaces/sagespawn.pyx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ AUTHOR:
2121
# ***************************************************************************
2222

2323
from pexpect import *
24-
from ptyprocess import PtyProcess
24+
from ptyprocess import PtyProcess, PtyProcessError
2525

2626
from cpython.ref cimport Py_INCREF
2727
from libc.signal cimport *
@@ -199,9 +199,12 @@ class SagePtyProcess(PtyProcess):
199199
# but the default (UTF-8) will do now, since I don't
200200
# think we have any non-ASCII quit_strings anyways.
201201
self.write(str_to_bytes(self.quit_string))
202-
except (OSError, IOError):
202+
except (OSError, IOError, PtyProcessError):
203203
pass
204-
self.fileobj.close()
204+
try:
205+
self.fileobj.close()
206+
except (OSError, IOError, PtyProcessError):
207+
pass
205208
self.fd = -1
206209
self.closed = 1
207210
self.terminate_async()

0 commit comments

Comments
 (0)