[pypy-svn] r43823 - in pypy/branch/kill-ctypes/pypy: interpreter module/posix

fijal at codespeak.net fijal at codespeak.net
Mon May 28 22:27:27 CEST 2007


Author: fijal
Date: Mon May 28 22:27:27 2007
New Revision: 43823

Modified:
   pypy/branch/kill-ctypes/pypy/interpreter/error.py
   pypy/branch/kill-ctypes/pypy/module/posix/interp_posix.py
Log:
Move wrap_oserror to a more convinient place


Modified: pypy/branch/kill-ctypes/pypy/interpreter/error.py
==============================================================================
--- pypy/branch/kill-ctypes/pypy/interpreter/error.py	(original)
+++ pypy/branch/kill-ctypes/pypy/interpreter/error.py	Mon May 28 22:27:27 2007
@@ -222,6 +222,19 @@
     # 31: ANSI color code "red"
     ansi_print(text, esc="31", file=file, newline=newline)
 
+def wrap_oserror(space, e): 
+    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,
+                                  space.wrap(errno),
+                                  space.wrap(msg))
+    return OperationError(space.w_OSError, w_error)
+
+
 ### installing the excepthook for OperationErrors
 ##def operr_excepthook(exctype, value, traceback):
 ##    if issubclass(exctype, OperationError):

Modified: pypy/branch/kill-ctypes/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/branch/kill-ctypes/pypy/module/posix/interp_posix.py	(original)
+++ pypy/branch/kill-ctypes/pypy/module/posix/interp_posix.py	Mon May 28 22:27:27 2007
@@ -1,21 +1,9 @@
 from pypy.interpreter.baseobjspace import ObjSpace, W_Root
 from pypy.rlib.rarithmetic import intmask
 from pypy.rlib import ros
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, wrap_oserror
 
 import os
-
-def wrap_oserror(space, e): 
-    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,
-                                  space.wrap(errno),
-                                  space.wrap(msg))
-    return OperationError(space.w_OSError, w_error)
                           
 def open(space, fname, flag, mode=0777):
     """Open a file (for low level IO).



More information about the Pypy-commit mailing list