[pypy-svn] r64581 - in pypy/branch/unicode_filename/pypy: module/_file module/posix rlib
afa at codespeak.net
afa at codespeak.net
Thu Apr 23 03:00:27 CEST 2009
Author: afa
Date: Thu Apr 23 03:00:25 2009
New Revision: 64581
Modified:
pypy/branch/unicode_filename/pypy/module/_file/interp_file.py
pypy/branch/unicode_filename/pypy/module/posix/interp_posix.py
pypy/branch/unicode_filename/pypy/rlib/streamio.py
Log:
Some progress towards open(someUnicode),
but how can I add _annspecialcase_ = 'specialize:argtype(0)' to os.open?
Modified: pypy/branch/unicode_filename/pypy/module/_file/interp_file.py
==============================================================================
--- pypy/branch/unicode_filename/pypy/module/_file/interp_file.py (original)
+++ pypy/branch/unicode_filename/pypy/module/_file/interp_file.py Thu Apr 23 03:00:25 2009
@@ -1,5 +1,5 @@
import py
-import os
+import os, sys
from pypy.rlib import streamio
from pypy.rlib.rarithmetic import r_longlong
from pypy.module._file.interp_stream import W_AbstractStream
@@ -11,6 +11,7 @@
from pypy.interpreter.typedef import interp_attrproperty_w
from pypy.interpreter.gateway import interp2app
+WIDE_FILENAMES = sys.platform == 'win32'
class W_File(W_AbstractStream):
"""An interp-level file object. This implements the same interface than
@@ -81,10 +82,18 @@
# file lock. They don't convert StreamErrors to OperationErrors, too.
def direct___init__(self, w_name, mode='r', buffering=-1):
- name = self.space.str_w(w_name)
- self.direct_close()
- self.check_mode_ok(mode)
- stream = streamio.open_file_as_stream(name, mode, buffering)
+ if WIDE_FILENAMES and self.space.is_true(
+ self.space.isinstance(w_name, self.space.w_unicode)):
+
+ name_u = self.space.unicode_w(w_name)
+ self.direct_close()
+ self.check_mode_ok(mode)
+ stream = streamio.open_file_as_stream(name_u, mode, buffering)
+ else:
+ name = self.space.str_w(w_name)
+ self.direct_close()
+ self.check_mode_ok(mode)
+ stream = streamio.open_file_as_stream(name, mode, buffering)
fd = stream.try_to_find_file_descriptor()
self.fdopenstream(stream, fd, mode, w_name)
Modified: pypy/branch/unicode_filename/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/branch/unicode_filename/pypy/module/posix/interp_posix.py (original)
+++ pypy/branch/unicode_filename/pypy/module/posix/interp_posix.py Thu Apr 23 03:00:25 2009
@@ -10,6 +10,7 @@
import os, sys
_WIN = sys.platform == 'win32'
+WIDE_FILENAMES = _WIN
def open(space, fname, flag, mode=0777):
"""Open a file (for low level IO).
@@ -144,7 +145,7 @@
return build_stat_result(space, st)
fstat.unwrap_spec = [ObjSpace, int]
-if _WIN:
+if WIDE_FILENAMES:
def wrapper(fn):
impl = extregistry.lookup(fn).lltypeimpl
def f(space, w_path, args):
Modified: pypy/branch/unicode_filename/pypy/rlib/streamio.py
==============================================================================
--- pypy/branch/unicode_filename/pypy/rlib/streamio.py (original)
+++ pypy/branch/unicode_filename/pypy/rlib/streamio.py Thu Apr 23 03:00:25 2009
@@ -76,6 +76,7 @@
stream = open_path_helper(path, os_flags, basemode == "a")
return construct_stream_tower(stream, buffering, universal, reading,
writing, binary)
+open_file_as_stream._annspecialcase_ = 'specialize:argtype(0)'
def _setfd_binary(fd):
pass
@@ -99,6 +100,7 @@
# XXX does this pass make sense?
pass
return DiskFile(fd)
+open_path_helper._annspecialcase_ = 'specialize:argtype(0)'
def decode_mode(mode):
if mode[0] == 'U':
More information about the Pypy-commit
mailing list