1. lahwran
  2. pypy


Matti Picus  committed 6a1d460

expose validate_fd via __pypy__ so posix.fdopen can use it

  • Participants
  • Parent commits 84e5827
  • Branches default

Comments (0)

Files changed (3)

File pypy/module/__pypy__/__init__.py

View file
  • Ignore whitespace
 from pypy.interpreter.mixedmodule import MixedModule
 from pypy.module.imp.importing import get_pyc_magic
 class BuildersModule(MixedModule):
     appleveldefs = {}
         'lookup_special'            : 'interp_magic.lookup_special',
         'do_what_I_mean'            : 'interp_magic.do_what_I_mean',
         'list_strategy'             : 'interp_magic.list_strategy',
+        'validate_fd'               : 'interp_magic.validate_fd',
     submodules = {

File pypy/module/__pypy__/interp_magic.py

View file
  • Ignore whitespace
 from pypy.interpreter.baseobjspace import ObjSpace, W_Root
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, wrap_oserror
 from pypy.interpreter.gateway import unwrap_spec
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.objspace.std.typeobject import MethodCache
 from pypy.objspace.std.mapdict import IndexCache
+from pypy.rlib import rposix
 def internal_repr(space, w_object):
     return space.wrap('%r' % (w_object,))
         w_msg = space.wrap("Can only get the list strategy of a list")
         raise OperationError(space.w_TypeError, w_msg)
+def validate_fd(space, fd):
+    try:
+        rposix.validate_fd(fd)
+    except OSError, e:
+        raise wrap_oserror(space, e)

File pypy/module/posix/app_posix.py

View file
  • Ignore whitespace
 from _structseq import structseqtype, structseqfield
+from __pypy__ import validate_fd
 # XXX we need a way to access the current module's globals more directly...
 import sys
         except IOError, e:
             raise OSError(e.errno, e.strerror, e.filename)
-    def _validate_fd(fd):
-        # XXX for the moment
-        return
+    _validate_fd = validate_fd
 # Capture file.fdopen at import time, as some code replaces
 # __builtins__.file with a custom function.