From c87ec3aececf4a0d3b746cfb6fb020244b2c48e7 Mon Sep 17 00:00:00 2001 From: Diego Argueta Date: Tue, 6 Aug 2019 10:56:49 -0700 Subject: [PATCH 1/6] Fix missing ENOTSUP on PyPy --- fs/osfs.py | 25 +++++++++++++------------ tests/test_osfs.py | 3 +-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/osfs.py b/fs/osfs.py index 10f8713a..40a0fdb6 100644 --- a/fs/osfs.py +++ b/fs/osfs.py @@ -39,7 +39,6 @@ sendfile = None # type: ignore # pragma: no cover from . import errors -from .errors import FileExists from .base import FS from .enums import ResourceType from ._fscompat import fsencode, fsdecode, fspath @@ -61,6 +60,7 @@ IO, List, Optional, + MutableSet, SupportsInt, Text, Tuple, @@ -420,17 +420,18 @@ def _check_copy(self, src_path, dst_path, overwrite=False): if sys.version_info[:2] < (3, 8) and sendfile is not None: - _sendfile_error_codes = frozenset( - { - errno.EIO, - errno.EINVAL, - errno.ENOSYS, - errno.ENOTSUP, # type: ignore - errno.EBADF, - errno.ENOTSOCK, - errno.EOPNOTSUPP, - } - ) + _sendfile_error_codes = { + errno.EIO, + errno.EINVAL, + errno.ENOSYS, + errno.EBADF, + errno.ENOTSOCK, + errno.EOPNOTSUPP, + } # type: MutableSet[int] + + # PyPy doesn't define ENOTSUP so we have to add it conditionally. + if hasattr(errno, "ENOTSUP"): + _sendfile_error_codes.add(errno.ENOTSUP) def copy(self, src_path, dst_path, overwrite=False): # type: (Text, Text, bool) -> None diff --git a/tests/test_osfs.py b/tests/test_osfs.py index 8ed361fb..e842dd00 100644 --- a/tests/test_osfs.py +++ b/tests/test_osfs.py @@ -10,7 +10,6 @@ import unittest from fs import osfs -from fs import fsencode, fsdecode from fs.path import relpath from fs import errors @@ -88,7 +87,7 @@ def test_expand_vars(self): def test_copy_sendfile(self): # try copying using sendfile with mock.patch.object(osfs, "sendfile") as sendfile: - sendfile.side_effect = OSError(errno.ENOTSUP, "sendfile not supported") + sendfile.side_effect = OSError(errno.ENOSYS, "sendfile not supported") self.test_copy() # check other errors are transmitted self.fs.touch("foo") From 91c1d2d0a5c40b16891d3fa2be1361f19c9f4db6 Mon Sep 17 00:00:00 2001 From: Diego Argueta Date: Tue, 6 Aug 2019 10:59:45 -0700 Subject: [PATCH 2/6] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f593b91f..e99d4850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed tests leaving tmp files - Fixed typing issues - Fixed link namespace returning bytes +- Fixed missing `errno.ENOTSUP` on PyPy. Closes [#338](https://github.com/PyFilesystem/pyfilesystem2/issues/338). ## [2.4.10] - 2019-07-29 From 8f6ab45edb68b940db4bc7b553dfcc4c54bc604b Mon Sep 17 00:00:00 2001 From: Diego Argueta Date: Tue, 6 Aug 2019 11:02:14 -0700 Subject: [PATCH 3/6] Start testing PyPy --- .travis.yml | 6 ++++++ setup.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 965e485f..fb741dec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,12 @@ matrix: - python: "3.4" env: - SETUPTOOLS=setuptools PIP=pip + - python: "pypy" + env: + - SETUPTOOLS=setuptools PIP=pip + - python: "pypy3.5" + env: + - SETUPTOOLS=setuptools PIP=pip before_install: - pip install $SETUPTOOLS $PIP -U diff --git a/setup.py b/setup.py index c1bcec3f..4cd43124 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,8 @@ "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", "Topic :: System :: Filesystems", ] From f4766f09bc226a77317d9dee604f3ca73abdd244 Mon Sep 17 00:00:00 2001 From: Diego Argueta Date: Tue, 6 Aug 2019 14:38:15 -0700 Subject: [PATCH 4/6] Attempt to fix Travis failure --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index fb741dec..9254ccd2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,9 +27,11 @@ matrix: env: - SETUPTOOLS=setuptools PIP=pip - python: "pypy" + sudo: true env: - SETUPTOOLS=setuptools PIP=pip - python: "pypy3.5" + sudo: true env: - SETUPTOOLS=setuptools PIP=pip From 682f76d4de135579938e4c1ca2d48f4e587e8b6f Mon Sep 17 00:00:00 2001 From: Diego Argueta Date: Thu, 8 Aug 2019 14:22:52 -0700 Subject: [PATCH 5/6] Fix PyPy3.5 RLock crash --- .travis.yml | 2 +- fs/ftpfs.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9254ccd2..1bfc7828 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ matrix: sudo: true env: - SETUPTOOLS=setuptools PIP=pip - - python: "pypy3.5" + - python: "pypy3.5-7.0" sudo: true env: - SETUPTOOLS=setuptools PIP=pip diff --git a/fs/ftpfs.py b/fs/ftpfs.py index 21e98a10..8ee1cb79 100644 --- a/fs/ftpfs.py +++ b/fs/ftpfs.py @@ -728,9 +728,8 @@ def _scandir(self, path, namespaces=None): for raw_info in self._parse_mlsx(lines): yield Info(raw_info) return - with self._lock: - for info in self._read_dir(_path).values(): - yield info + for info in self._read_dir(_path).values(): + yield info def scandir( self, From a7c3a96cddd2bf8a71cc3a2b1c5ae440b2571ec4 Mon Sep 17 00:00:00 2001 From: Diego Argueta Date: Wed, 7 Aug 2019 14:28:00 -0700 Subject: [PATCH 6/6] Remove unnecessary typing --- fs/osfs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/osfs.py b/fs/osfs.py index 40a0fdb6..0ae93884 100644 --- a/fs/osfs.py +++ b/fs/osfs.py @@ -60,7 +60,6 @@ IO, List, Optional, - MutableSet, SupportsInt, Text, Tuple, @@ -427,7 +426,7 @@ def _check_copy(self, src_path, dst_path, overwrite=False): errno.EBADF, errno.ENOTSOCK, errno.EOPNOTSUPP, - } # type: MutableSet[int] + } # PyPy doesn't define ENOTSUP so we have to add it conditionally. if hasattr(errno, "ENOTSUP"):