Index: src/org/python/modules/posix/PosixModule.java =================================================================== --- src/org/python/modules/posix/PosixModule.java (revision 7284) +++ src/org/python/modules/posix/PosixModule.java (working copy) @@ -110,10 +110,6 @@ dict.__setitem__("error", Py.OSError); dict.__setitem__("stat_result", PyStatResult.TYPE); - // Faster call paths - dict.__setitem__("lstat", new LstatFunction()); - dict.__setitem__("stat", new StatFunction()); - // Hide from Python Hider.hideFunctions(PosixModule.class, dict, os, nativePosix); dict.__setitem__("classDictInit", null); @@ -847,6 +843,32 @@ return new PyString(StringUtil.fromBytes(buf)); } + public static PyString __doc__lstat = new PyString( + "lstat(path) -> stat result\n\n" + + "Like stat(path), but do not follow symbolic links."); + public static PyObject lstat(PyObject pathObj) { + if (!(pathObj instanceof PyString)) { + throw Py.TypeError(String.format("coercing to Unicode: need string or buffer, %s " + + "found", pathObj.getType().fastGetName())); + } + String absolutePath = absolutePath(pathObj.toString()); + return PyStatResult.fromFileStat(posix.lstat(absolutePath)); + } + + public static PyString __doc__stat = new PyString( + "stat(path) -> stat result\n\n" + + "Perform a stat system call on the given path.\n\n" + + "Note that some platforms may return only a small subset of the\n" + + "standard fields"); + public static PyObject stat(PyObject pathObj) { + if (!(pathObj instanceof PyString)) { + throw Py.TypeError(String.format("coercing to Unicode: need string or buffer, %s " + + "found", pathObj.getType().fastGetName())); + } + String absolutePath = absolutePath(pathObj.toString()); + return PyStatResult.fromFileStat(posix.stat(absolutePath)); + } + /** * Helper function for the subprocess module, returns the potential shell commands for * this OS. @@ -928,42 +950,4 @@ public static String getOSName() { return os.getModuleName(); } - - static class LstatFunction extends PyBuiltinFunction { - LstatFunction() { - super("lstat", - "lstat(path) -> stat result\n\n" + - "Like stat(path), but do not follow symbolic links."); - } - - @Override - public PyObject __call__(ThreadState state, PyObject pathObj) { - if (!(pathObj instanceof PyString)) { - throw Py.TypeError(String.format("coercing to Unicode: need string or buffer, %s " + - "found", pathObj.getType().fastGetName())); - } - String absolutePath = absolutePath(pathObj.toString()); - return PyStatResult.fromFileStat(posix.lstat(absolutePath)); - } - } - - static class StatFunction extends PyBuiltinFunction { - StatFunction() { - super("stat", - "stat(path) -> stat result\n\n" + - "Perform a stat system call on the given path.\n\n" + - "Note that some platforms may return only a small subset of the\n" + - "standard fields"); - } - - @Override - public PyObject __call__(ThreadState state, PyObject pathObj) { - if (!(pathObj instanceof PyString)) { - throw Py.TypeError(String.format("coercing to Unicode: need string or buffer, %s " + - "found", pathObj.getType().fastGetName())); - } - String absolutePath = absolutePath(pathObj.toString()); - return PyStatResult.fromFileStat(posix.stat(absolutePath)); - } - } }