Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Fixed performance bugs in `fs.copy.copy_dir_if_newer`. Test cases were adapted to catch those bugs in the future.
- Fixed precision bug for timestamps in `fs.OSFS.setinfo`.
- Fixed `ResourceLocked` error translation on Windows [#484](https://github.com/PyFilesystem/pyfilesystem2/issues/484).


## [2.4.13] - 2021-03-27
Expand Down
4 changes: 3 additions & 1 deletion fs/error_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def __exit__(
_errno = exc_value.errno
fserror = os_errors.get(_errno, errors.OperationFailed)
if _errno == errno.EACCES and sys.platform == "win32":
if getattr(exc_value, "args", None) == 32: # pragma: no cover
windows_error = getattr(exc_value, "winerror", 0)
exception_args = getattr(exc_value, "args", None) or (0,)
if windows_error == 32 or exception_args[0] == errno.EACCES: # pragma: no cover
fserror = errors.ResourceLocked
reraise(fserror, fserror(self._path, exc=exc_value), traceback)

Expand Down
11 changes: 11 additions & 0 deletions tests/test_error_tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import unicode_literals

import errno
import sys
import unittest

import fs.errors
Expand All @@ -23,3 +24,13 @@ def test_convert_enametoolong(self):
raise exception
self.assertEqual(ctx.exception.exc, exception)
self.assertEqual(ctx.exception.path, "/tmp/test")

@unittest.skipIf(sys.platform != "win32", "requires Windows")
def test_convert_resourcelocked_windows(self):
exception = OSError(32, "resource locked")
with self.assertRaises(fs.errors.ResourceLocked) as ctx:
with convert_os_errors("stat", "/tmp/test"):
raise exception

self.assertEqual(ctx.exception.exc, exception)
self.assertEqual(ctx.exception.path, "/tmp/test")