[pypy-svn] r47528 - pypy/dist/pypy/interpreter

fijal at codespeak.net fijal at codespeak.net
Thu Oct 18 09:50:41 CEST 2007


Author: fijal
Date: Thu Oct 18 09:50:40 2007
New Revision: 47528

Modified:
   pypy/dist/pypy/interpreter/error.py
Log:
Add custom exception possibility to wrap_oserror


Modified: pypy/dist/pypy/interpreter/error.py
==============================================================================
--- pypy/dist/pypy/interpreter/error.py	(original)
+++ pypy/dist/pypy/interpreter/error.py	Thu Oct 18 09:50:40 2007
@@ -222,18 +222,19 @@
     # 31: ANSI color code "red"
     ansi_print(text, esc="31", file=file, newline=newline)
 
-def wrap_oserror(space, e): 
+def wrap_oserror(space, e, exception_name='w_OSError'): 
     assert isinstance(e, OSError) 
     errno = e.errno
     try:
         msg = os.strerror(errno)
     except ValueError:
         msg = 'error %d' % errno
-    w_error = space.call_function(space.w_OSError,
+    exc = getattr(space, exception_name)
+    w_error = space.call_function(exc,
                                   space.wrap(errno),
                                   space.wrap(msg))
-    return OperationError(space.w_OSError, w_error)
-
+    return OperationError(exc, w_error)
+wrap_oserror._annspecialcase_ = 'specialize:arg(2)'
 
 ### installing the excepthook for OperationErrors
 ##def operr_excepthook(exctype, value, traceback):



More information about the Pypy-commit mailing list