[pypy-commit] pypy py3.5: (arigato, plan_rich) catch OSError in descr_stat and wrap it into an applevel exception
plan_rich
pypy.commits at gmail.com
Fri Oct 14 06:00:12 EDT 2016
Author: Richard Plangger <planrichi at gmail.com>
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
More information about the pypy-commit
mailing list