Author: Richard Plangger <[email protected]>
Branch: py3.5
Changeset: r87776:1faec1d31737
Date: 2016-10-14 11:50 +0200
http://bitbucket.org/pypy/pypy/changeset/1faec1d31737/
Log: (arigato, plan_rich) catch OSError in descr_stat and wrap it into an
applevel exception
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
@@ -284,8 +284,11 @@
@unwrap_spec(follow_symlinks=bool)
def descr_stat(self, space, __kwonly__, follow_symlinks=True):
"""return stat_result object for the entry; cached per entry"""
- st = self.get_stat_or_lstat(follow_symlinks)
- return build_stat_result(self.space, st)
+ try:
+ st = self.get_stat_or_lstat(follow_symlinks)
+ except OSError as e:
+ raise wrap_oserror2(space, e, self.fget_path(space))
+ return build_stat_result(space, st)
def descr_inode(self, space):
return space.wrap(self.inode)
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
@@ -145,6 +145,7 @@
assert not d.is_file()
assert not d.is_dir()
assert d.is_symlink()
+ raises(OSError, d.stat)
def test_dir6(self):
posix = self.posix
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit