Author: Philip Jenvey <pjen...@underboss.org> Branch: py3k Changeset: r63811:0a4ff9405074 Date: 2013-05-02 16:42 -0700 http://bitbucket.org/pypy/pypy/changeset/0a4ff9405074/
Log: special case windows unicode paths diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py --- a/pypy/module/imp/importing.py +++ b/pypy/module/imp/importing.py @@ -15,9 +15,11 @@ from rpython.rlib.streamio import StreamErrors from rpython.rlib.objectmodel import we_are_translated, specialize from rpython.rlib.signature import signature -from rpython.rlib import types +from rpython.rlib import rposix, types from pypy.module.sys.version import PYPY_VERSION +_WIN32 = sys.platform == 'win32' + SEARCH_ERROR = 0 PY_SOURCE = 1 PY_COMPILED = 2 @@ -415,20 +417,30 @@ if space.is_true(w_loader): return w_loader +class _WIN32Path(object): + def __init__(self, path): + self.path = path + + def as_unicode(self): + return self.path class W_NullImporter(W_Root): def __init__(self, space): pass - @unwrap_spec(path='fsencode') - def descr_init(self, space, path): + def descr_init(self, space, w_path): + self._descr_init(space, w_path, _WIN32) + + @specialize.arg(3) + def _descr_init(self, space, w_path, win32): + path = space.unicode0_w(w_path) if win32 else space.fsencode_w(w_path) if not path: raise OperationError(space.w_ImportError, space.wrap( "empty pathname")) # Directory should not exist try: - st = os.stat(path) + st = rposix.stat(_WIN32Path(path) if win32 else path) except OSError: pass else: diff --git a/pypy/module/imp/test/support.py b/pypy/module/imp/test/support.py --- a/pypy/module/imp/test/support.py +++ b/pypy/module/imp/test/support.py @@ -7,7 +7,7 @@ testfn = u'test_tmp' testfn_unencodable = None - if sys.platform == 'nt': + if sys.platform == 'win32': testfn_unencodable = testfn + u"-\u5171\u0141\u2661\u0363\uDC80" elif sys.platform != 'darwin': try: _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit