Debian Codegraph @

pypy/interpreter/streamutil.py

raw symbols SCIP
1 from rpython.rlib.streamio import StreamError
2 from pypy.interpreter.error import OperationError, wrap_oserror2
3
4 def wrap_streamerror(space, e, w_filename=None):
5 if isinstance(e, StreamError):
6 return OperationError(space.w_ValueError,
7 space.newtext(e.message))
8 elif isinstance(e, OSError):
9 return wrap_oserror_as_ioerror(space, e, w_filename)
10 else:
11 # should not happen: wrap_streamerror() is only called when
12 # StreamErrors = (OSError, StreamError) are raised
13 return OperationError(space.w_IOError, space.w_None)
14
15 def wrap_oserror_as_ioerror(space, e, w_filename=None):
16 return wrap_oserror2(space, e, w_filename,
17 w_exception_class=space.w_IOError)