aiopath icon indicating copy to clipboard operation
aiopath copied to clipboard

Import Fails on Python 3.7.0

Open curtis-lamp opened this issue 2 years ago • 0 comments

In 3.7.0 the _ignore_error function doesn't exist in pathlib, so aiopath fails to import.

Adding a try/except block around this import that on except executes the following from cpython would solve this issue.

_WINERROR_NOT_READY = 21  # drive exists but is not accessible
_WINERROR_INVALID_NAME = 123  # fix for bpo-35306
_WINERROR_CANT_RESOLVE_FILENAME = 1921  # broken symlink pointing to itself

_IGNORED_ERRNOS = (ENOENT, ENOTDIR, EBADF, ELOOP)

_IGNORED_WINERRORS = (
    _WINERROR_NOT_READY,
    _WINERROR_INVALID_NAME,
    _WINERROR_CANT_RESOLVE_FILENAME)

def _ignore_error(exception):
    return (getattr(exception, 'errno', None) in _IGNORED_ERRNOS or
            getattr(exception, 'winerror', None) in _IGNORED_WINERRORS)

This would have to be in a 0.5.13 release to support older pythons. I'll happily submit a PR for this.

curtis-lamp avatar Feb 20 '22 19:02 curtis-lamp