Skip to content

Commit 2d9189d

Browse files
darguetawillmcgugan
authored andcommitted
Fix missing ENOTSUP on PyPy (#339)
* Fix missing ENOTSUP on PyPy * Update CHANGELOG * Start testing PyPy * Attempt to fix Travis failure * Remove unnecessary typing * Fix PyPy3.5 RLock crash
1 parent b78dad7 commit 2d9189d

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2323
- Fixed incorrect imports of `mock` on Python 3
2424
- Removed some unused imports and unused `requirements.txt` file
2525
- Added mypy checks to Travis
26+
- Fixed missing `errno.ENOTSUP` on PyPy. Closes [#338](https://github.com/PyFilesystem/pyfilesystem2/issues/338).
2627

2728
### Changed
2829

fs/ftpfs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,8 @@ def _scandir(self, path, namespaces=None):
728728
for raw_info in self._parse_mlsx(lines):
729729
yield Info(raw_info)
730730
return
731-
with self._lock:
732-
for info in self._read_dir(_path).values():
733-
yield info
731+
for info in self._read_dir(_path).values():
732+
yield info
734733

735734
def scandir(
736735
self,

fs/osfs.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -421,17 +421,18 @@ def _check_copy(self, src_path, dst_path, overwrite=False):
421421

422422
if sys.version_info[:2] < (3, 8) and sendfile is not None:
423423

424-
_sendfile_error_codes = frozenset(
425-
{
426-
errno.EIO,
427-
errno.EINVAL,
428-
errno.ENOSYS,
429-
errno.ENOTSUP, # type: ignore
430-
errno.EBADF,
431-
errno.ENOTSOCK,
432-
errno.EOPNOTSUPP,
433-
}
434-
)
424+
_sendfile_error_codes = {
425+
errno.EIO,
426+
errno.EINVAL,
427+
errno.ENOSYS,
428+
errno.EBADF,
429+
errno.ENOTSOCK,
430+
errno.EOPNOTSUPP,
431+
}
432+
433+
# PyPy doesn't define ENOTSUP so we have to add it conditionally.
434+
if hasattr(errno, "ENOTSUP"):
435+
_sendfile_error_codes.add(errno.ENOTSUP)
435436

436437
def copy(self, src_path, dst_path, overwrite=False):
437438
# type: (Text, Text, bool) -> None

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"Programming Language :: Python :: 3.5",
1717
"Programming Language :: Python :: 3.6",
1818
"Programming Language :: Python :: 3.7",
19+
"Programming Language :: Python :: Implementation :: CPython",
20+
"Programming Language :: Python :: Implementation :: PyPy",
1921
"Topic :: System :: Filesystems",
2022
]
2123

tests/test_osfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_expand_vars(self):
9191
def test_copy_sendfile(self):
9292
# try copying using sendfile
9393
with mock.patch.object(osfs, "sendfile") as sendfile:
94-
sendfile.side_effect = OSError(errno.ENOTSUP, "sendfile not supported")
94+
sendfile.side_effect = OSError(errno.ENOSYS, "sendfile not supported")
9595
self.test_copy()
9696
# check other errors are transmitted
9797
self.fs.touch("foo")

0 commit comments

Comments
 (0)