[pypy-svn] r76168 - in pypy/branch/unicode_filename-2/pypy/module: _file posix
afa at codespeak.net
afa at codespeak.net
Mon Jul 12 23:56:49 CEST 2010
Author: afa
Date: Mon Jul 12 23:56:33 2010
New Revision: 76168
Modified:
pypy/branch/unicode_filename-2/pypy/module/_file/interp_file.py
pypy/branch/unicode_filename-2/pypy/module/posix/interp_posix.py
Log:
Another attempt, lambda is probably not RPython at all.
Modified: pypy/branch/unicode_filename-2/pypy/module/_file/interp_file.py
==============================================================================
--- pypy/branch/unicode_filename-2/pypy/module/_file/interp_file.py (original)
+++ pypy/branch/unicode_filename-2/pypy/module/_file/interp_file.py Mon Jul 12 23:56:33 2010
@@ -85,9 +85,8 @@
self.direct_close()
self.w_name = w_name
self.check_mode_ok(mode)
- stream = dispatch_filename(
- self.space, w_name,
- lambda name: streamio.open_file_as_stream(name, mode, buffering))
+ stream = dispatch_filename(streamio.open_file_as_stream)(
+ self.space, w_name, mode, buffering)
fd = stream.try_to_find_file_descriptor()
self.fdopenstream(stream, fd, mode)
Modified: pypy/branch/unicode_filename-2/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/branch/unicode_filename-2/pypy/module/posix/interp_posix.py (original)
+++ pypy/branch/unicode_filename-2/pypy/module/posix/interp_posix.py Mon Jul 12 23:56:33 2010
@@ -24,22 +24,23 @@
def gettext(self):
return self.space.unicode_w(self.w_obj)
- at specialize.arg(2)
-def dispatch_filename(space, w_fname, callable):
- if space.isinstance_w(w_fname, space.w_unicode):
- fname = FileEncoder(space, w_fname)
- return callable(fname)
- else:
- fname = space.str_w(w_fname)
- return callable(fname)
+ at specialize.memo()
+def dispatch_filename(func):
+ def dispatch(space, w_fname, *args):
+ if space.isinstance_w(w_fname, space.w_unicode):
+ fname = FileEncoder(space, w_fname)
+ return func(fname, *args)
+ else:
+ fname = space.str_w(w_fname)
+ return func(fname, *args)
+ return dispatch
def open(space, w_fname, flag, mode=0777):
"""Open a file (for low level IO).
Return a file descriptor (a small integer)."""
try:
- fd = dispatch_filename(
- space, w_fname,
- lambda fname: rposix.open(fname, flag, mode))
+ fd = dispatch_filename(rposix.open)(
+ space, w_fname, flag, mode)
except OSError, e:
raise wrap_oserror2(space, e, w_fname)
return space.wrap(fd)
More information about the Pypy-commit
mailing list