[Jython-checkins] jython: Make os.lstat(path) pass trailing slashes in the path to the native posix
jim.baker
jython-checkins at python.org
Sat Jun 28 03:28:03 CEST 2014
http://hg.python.org/jython/rev/58b54d33f50d
changeset: 7317:58b54d33f50d
user: Indra Talip <indra.talip at gmail.com>
date: Sat Mar 29 16:14:56 2014 +1100
summary:
Make os.lstat(path) pass trailing slashes in the path to the native posix library.
This causes an exception to bubble up in the case that the path exists but is
not a directory thereby making it consistent with CPython. This also fixes two of
the test_glob regression tests.
files:
src/org/python/modules/posix/PosixModule.java | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/src/org/python/modules/posix/PosixModule.java b/src/org/python/modules/posix/PosixModule.java
--- a/src/org/python/modules/posix/PosixModule.java
+++ b/src/org/python/modules/posix/PosixModule.java
@@ -944,7 +944,15 @@
@Override
public PyObject __call__(PyObject path) {
- return PyStatResult.fromFileStat(posix.lstat(absolutePath(path)));
+ String absolutePath = absolutePath(path);
+
+ // round tripping from a string to a file to a string loses
+ // trailing slashes so add them back back in to get correct posix.lstat
+ // behaviour if path is not a directory.
+ if (asPath(path).endsWith(File.separator)) {
+ absolutePath = absolutePath + File.separator;
+ }
+ return PyStatResult.fromFileStat(posix.lstat(absolutePath));
}
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list