Skip to content

Commit

Permalink
Merge pull request #36 from takluyver/i35
Browse files Browse the repository at this point in the history
Use PtyProcessError instead of ExceptionPexpect
  • Loading branch information
takluyver authored Feb 7, 2018
2 parents 4316bca + f673a54 commit df9b55b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions ptyprocess/_fork_pty.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import errno

from pty import (STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO, CHILD)
from .util import PtyProcessError

def fork_pty():
'''This implements a substitute for the forkpty system call. This
Expand Down Expand Up @@ -63,7 +64,7 @@ def pty_make_controlling_tty(tty_fd):
try:
fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY)
os.close(fd)
raise ExceptionPexpect("OSError of errno.ENXIO should be raised.")
raise PtyProcessError("OSError of errno.ENXIO should be raised.")
except OSError as err:
if err.errno != errno.ENXIO:
raise
Expand All @@ -74,4 +75,4 @@ def pty_make_controlling_tty(tty_fd):

# Verify we now have a controlling tty.
fd = os.open("/dev/tty", os.O_WRONLY)
os.close(fd)
os.close(fd)
5 changes: 1 addition & 4 deletions ptyprocess/ptyprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Constants
from pty import (STDIN_FILENO, CHILD)

from .util import which
from .util import which, PtyProcessError

_platform = sys.platform.lower()

Expand Down Expand Up @@ -88,9 +88,6 @@ def _make_eof_intr():
_INTR = _byte(intr)
_EOF = _byte(eof)

class PtyProcessError(Exception):
"""Generic error class for this package."""

# setecho and setwinsize are pulled out here because on some platforms, we need
# to do this from the child before we exec()

Expand Down
6 changes: 5 additions & 1 deletion ptyprocess/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ def _access_check(fn, mode):
name = os.path.join(dir, thefile)
if _access_check(name, mode):
return name
return None
return None


class PtyProcessError(Exception):
"""Generic error class for this package."""

0 comments on commit df9b55b

Please sign in to comment.