[pypy-svn] r77967 - pypy/branch/fast-forward/pypy/module/_io

afa at codespeak.net afa at codespeak.net
Fri Oct 15 08:40:02 CEST 2010


Author: afa
Date: Fri Oct 15 08:40:00 2010
New Revision: 77967

Modified:
   pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py
Log:
Try to fix translation again


Modified: pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py	Fri Oct 15 08:40:00 2010
@@ -3,8 +3,12 @@
 from pypy.interpreter.gateway import interp2app, unwrap_spec, Arguments
 from pypy.interpreter.baseobjspace import ObjSpace, W_Root
 from pypy.interpreter.error import OperationError, wrap_oserror2
+from os import O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_TRUNC
 import os
 
+O_BINARY = getattr(os, "O_BINARY", 0)
+O_APPEND = getattr(os, "O_APPEND", 0)
+
 def _bad_mode(space):
     raise OperationError(space.w_ValueError, space.wrap(
         "Must have exactly one of read/write/append mode"))
@@ -28,13 +32,13 @@
                 _bad_mode(space)
             rwa = True
             writable = True
-            flags |= os.O_CREAT | os.O_TRUNC
+            flags |= O_CREAT | O_TRUNC
         elif s == 'a':
             if rwa:
                 _bad_mode(space)
             rwa = True
             writable = True
-            flags |= os.O_CREAT
+            flags |= O_CREAT
             append = True
         elif s == 'b':
             pass
@@ -51,17 +55,16 @@
         _bad_mode(space)
 
     if readable and writable:
-        flags |= os.O_RDWR
+        flags |= O_RDWR
     elif readable:
-        flags |= os.O_RDONLY
+        flags |= O_RDONLY
     else:
-        flags |= os.O_WRONLY
+        flags |= O_WRONLY
 
-    if hasattr(os, 'O_BINARY'):
-        flags |= os.O_BINARY
+    flags |= O_BINARY
 
-    if hasattr(os, 'O_APPEND') and append:
-        flags |= os.O_APPEND
+    if append:
+        flags |= O_APPEND
 
     return readable, writable, flags
 



More information about the Pypy-commit mailing list