Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3.6
Changeset: r93388:07c74faf3629
Date: 2017-12-12 01:01 +0100
http://bitbucket.org/pypy/pypy/changeset/07c74faf3629/
Log: os.fspath() accepts a DirEntry
diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -82,6 +82,7 @@
'get_terminal_size': 'interp_posix.get_terminal_size',
'scandir': 'interp_scandir.scandir',
+ 'DirEntry': 'interp_scandir.W_DirEntry',
'get_inheritable': 'interp_posix.get_inheritable',
'set_inheritable': 'interp_posix.set_inheritable',
'fspath': 'interp_posix.fspath',
diff --git a/pypy/module/posix/interp_scandir.py
b/pypy/module/posix/interp_scandir.py
--- a/pypy/module/posix/interp_scandir.py
+++ b/pypy/module/posix/interp_scandir.py
@@ -335,6 +335,7 @@
path = GetSetProperty(W_DirEntry.fget_path,
doc="the entry's full path name; equivalent to "
"os.path.join(scandir_path, entry.name)"),
+ __fspath__ = interp2app(W_DirEntry.fget_path),
is_dir = interp2app(W_DirEntry.descr_is_dir),
is_file = interp2app(W_DirEntry.descr_is_file),
is_symlink = interp2app(W_DirEntry.descr_is_symlink),
diff --git a/pypy/module/posix/test/test_scandir.py
b/pypy/module/posix/test/test_scandir.py
--- a/pypy/module/posix/test/test_scandir.py
+++ b/pypy/module/posix/test/test_scandir.py
@@ -169,8 +169,14 @@
def test_repr(self):
posix = self.posix
d = next(posix.scandir(self.dir1))
+ assert isinstance(d, posix.DirEntry)
assert repr(d) == "<DirEntry 'file1'>"
+ def test_fspath(self):
+ posix = self.posix
+ d = next(posix.scandir(self.dir1))
+ assert self.posix.fspath(d).endswith('dir1/file1')
+
def test_resource_warning(self):
posix = self.posix
import warnings, gc
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit