Author: Brian Kearns <bdkea...@gmail.com> Branch: stdlib-2.7.6 Changeset: r69784:a4119279c94c Date: 2014-03-07 11:49 -0500 http://bitbucket.org/pypy/pypy/changeset/a4119279c94c/
Log: wip: checksignals in _file diff --git a/pypy/module/_file/interp_file.py b/pypy/module/_file/interp_file.py --- a/pypy/module/_file/interp_file.py +++ b/pypy/module/_file/interp_file.py @@ -109,12 +109,13 @@ # file lock. They don't convert StreamErrors to OperationErrors, too. @unwrap_spec(mode=str, buffering=int) - def direct___init__(self, w_name, mode='r', buffering=-1): + def direct___init__(self, space, w_name, mode='r', buffering=-1): self.direct_close() self.w_name = w_name self.check_mode_ok(mode) stream = dispatch_filename(streamio.open_file_as_stream)( - self.space, w_name, mode, buffering) + self.space, w_name, mode, buffering, + space.getexecutioncontext().checksignals) fd = stream.try_to_find_file_descriptor() self.check_not_dir(fd) self.fdopenstream(stream, fd, mode) diff --git a/rpython/rlib/streamio.py b/rpython/rlib/streamio.py --- a/rpython/rlib/streamio.py +++ b/rpython/rlib/streamio.py @@ -76,9 +76,9 @@ @specialize.argtype(0) -def open_file_as_stream(path, mode="r", buffering=-1): +def open_file_as_stream(path, mode="r", buffering=-1, signal_checker=None): os_flags, universal, reading, writing, basemode, binary = decode_mode(mode) - stream = open_path_helper(path, os_flags, basemode == "a") + stream = open_path_helper(path, os_flags, basemode == "a", signal_checker) return construct_stream_tower(stream, buffering, universal, reading, writing, binary) @@ -95,7 +95,7 @@ writing, binary) @specialize.argtype(0) -def open_path_helper(path, os_flags, append): +def open_path_helper(path, os_flags, append, signal_checker=None): # XXX for now always return DiskFile fd = rposix.open(path, os_flags, 0666) if append: @@ -104,7 +104,7 @@ except OSError: # XXX does this pass make sense? pass - return DiskFile(fd) + return DiskFile(fd, signal_checker) def decode_mode(mode): if mode[0] == 'U': @@ -277,8 +277,9 @@ class DiskFile(Stream): """Standard I/O basis stream using os.open/close/read/write/lseek""" - def __init__(self, fd): + def __init__(self, fd, signal_checker=None): self.fd = fd + self.signal_checker = signal_checker def seek(self, offset, whence): os.lseek(self.fd, offset, whence) @@ -294,6 +295,8 @@ except OSError, e: if e.errno != errno.EINTR: raise + if self.signal_checker is not None: + self.signal_checker() # else try again def readline(self): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit