Author: Armin Rigo <ar...@tunes.org> Branch: release-2.2.x Changeset: r67976:7341987b8055 Date: 2013-11-12 13:58 +0100 http://bitbucket.org/pypy/pypy/changeset/7341987b8055/
Log: Use getwinerror() here diff --git a/pypy/module/posix/app_startfile.py b/pypy/module/posix/app_startfile.py --- a/pypy/module/posix/app_startfile.py +++ b/pypy/module/posix/app_startfile.py @@ -11,9 +11,9 @@ """) self.NULL = ffi.NULL self.cast = ffi.cast - self.libK = ffi.dlopen("Kernel32.dll") - self.libS = ffi.dlopen("Shell32.dll") + self.lib = ffi.dlopen("Shell32.dll") self.SW_SHOWNORMAL = 1 + self.getwinerror = ffi.getwinerror _cffi_wrapper = None @@ -29,21 +29,16 @@ if isinstance(filepath, str): if isinstance(operation, unicode): operation = operation.encode("ascii") - rc = w.libS.ShellExecuteA(w.NULL, operation, filepath, - w.NULL, w.NULL, w.SW_SHOWNORMAL) + rc = w.lib.ShellExecuteA(w.NULL, operation, filepath, + w.NULL, w.NULL, w.SW_SHOWNORMAL) elif isinstance(filepath, unicode): if isinstance(operation, str): operation = operation.decode("ascii") - rc = w.libS.ShellExecuteW(w.NULL, operation, filepath, - w.NULL, w.NULL, w.SW_SHOWNORMAL) + rc = w.lib.ShellExecuteW(w.NULL, operation, filepath, + w.NULL, w.NULL, w.SW_SHOWNORMAL) else: raise TypeError("argument 1 must be str or unicode") rc = int(w.cast("uintptr_t", rc)) if rc <= 32: - code = w.libK.GetLastError() - try: - import _rawffi - msg = _rawffi.FormatError(code) - except ImportError: - msg = 'Error %s' % code + code, msg = w.getwinerror() raise WindowsError(code, msg, filepath) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit