aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/pathlib.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/Lib/pathlib.py
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
downloadydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Lib/pathlib.py')
-rw-r--r--contrib/tools/python3/src/Lib/pathlib.py438
1 files changed, 219 insertions, 219 deletions
diff --git a/contrib/tools/python3/src/Lib/pathlib.py b/contrib/tools/python3/src/Lib/pathlib.py
index a15b71e548..7aeda14a14 100644
--- a/contrib/tools/python3/src/Lib/pathlib.py
+++ b/contrib/tools/python3/src/Lib/pathlib.py
@@ -7,7 +7,7 @@ import posixpath
import re
import sys
from _collections_abc import Sequence
-from errno import EINVAL, ENOENT, ENOTDIR, EBADF, ELOOP
+from errno import EINVAL, ENOENT, ENOTDIR, EBADF, ELOOP
from operator import attrgetter
from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO
from urllib.parse import quote_from_bytes as urlquote_from_bytes
@@ -34,13 +34,13 @@ __all__ = [
# Internals
#
-# EBADF - guard against macOS `stat` throwing EBADF
-_IGNORED_ERROS = (ENOENT, ENOTDIR, EBADF, ELOOP)
+# EBADF - guard against macOS `stat` throwing EBADF
+_IGNORED_ERROS = (ENOENT, ENOTDIR, EBADF, ELOOP)
_IGNORED_WINERRORS = (
21, # ERROR_NOT_READY - drive exists but is not accessible
- 123, # ERROR_INVALID_NAME - fix for bpo-35306
- 1921, # ERROR_CANT_RESOLVE_FILENAME - fix for broken symlink pointing to itself
+ 123, # ERROR_INVALID_NAME - fix for bpo-35306
+ 1921, # ERROR_CANT_RESOLVE_FILENAME - fix for broken symlink pointing to itself
)
def _ignore_error(exception):
@@ -132,25 +132,25 @@ class _WindowsFlavour(_Flavour):
ext_namespace_prefix = '\\\\?\\'
reserved_names = (
- {'CON', 'PRN', 'AUX', 'NUL', 'CONIN$', 'CONOUT$'} |
- {'COM%s' % c for c in '123456789\xb9\xb2\xb3'} |
- {'LPT%s' % c for c in '123456789\xb9\xb2\xb3'}
+ {'CON', 'PRN', 'AUX', 'NUL', 'CONIN$', 'CONOUT$'} |
+ {'COM%s' % c for c in '123456789\xb9\xb2\xb3'} |
+ {'LPT%s' % c for c in '123456789\xb9\xb2\xb3'}
)
# Interesting findings about extended paths:
- # * '\\?\c:\a' is an extended path, which bypasses normal Windows API
- # path processing. Thus relative paths are not resolved and slash is not
- # translated to backslash. It has the native NT path limit of 32767
- # characters, but a bit less after resolving device symbolic links,
- # such as '\??\C:' => '\Device\HarddiskVolume2'.
- # * '\\?\c:/a' looks for a device named 'C:/a' because slash is a
- # regular name character in the object namespace.
- # * '\\?\c:\foo/bar' is invalid because '/' is illegal in NT filesystems.
- # The only path separator at the filesystem level is backslash.
- # * '//?/c:\a' and '//?/c:/a' are effectively equivalent to '\\.\c:\a' and
- # thus limited to MAX_PATH.
- # * Prior to Windows 8, ANSI API bytes paths are limited to MAX_PATH,
- # even with the '\\?\' prefix.
+ # * '\\?\c:\a' is an extended path, which bypasses normal Windows API
+ # path processing. Thus relative paths are not resolved and slash is not
+ # translated to backslash. It has the native NT path limit of 32767
+ # characters, but a bit less after resolving device symbolic links,
+ # such as '\??\C:' => '\Device\HarddiskVolume2'.
+ # * '\\?\c:/a' looks for a device named 'C:/a' because slash is a
+ # regular name character in the object namespace.
+ # * '\\?\c:\foo/bar' is invalid because '/' is illegal in NT filesystems.
+ # The only path separator at the filesystem level is backslash.
+ # * '//?/c:\a' and '//?/c:/a' are effectively equivalent to '\\.\c:\a' and
+ # thus limited to MAX_PATH.
+ # * Prior to Windows 8, ANSI API bytes paths are limited to MAX_PATH,
+ # even with the '\\?\' prefix.
def splitroot(self, part, sep=sep):
first = part[0:1]
@@ -197,9 +197,9 @@ class _WindowsFlavour(_Flavour):
def casefold_parts(self, parts):
return [p.lower() for p in parts]
- def compile_pattern(self, pattern):
- return re.compile(fnmatch.translate(pattern), re.IGNORECASE).fullmatch
-
+ def compile_pattern(self, pattern):
+ return re.compile(fnmatch.translate(pattern), re.IGNORECASE).fullmatch
+
def resolve(self, path, strict=False):
s = str(path)
if not s:
@@ -240,16 +240,16 @@ class _WindowsFlavour(_Flavour):
def is_reserved(self, parts):
# NOTE: the rules for reserved names seem somewhat complicated
- # (e.g. r"..\NUL" is reserved but not r"foo\NUL" if "foo" does not
- # exist). We err on the side of caution and return True for paths
- # which are not considered reserved by Windows.
+ # (e.g. r"..\NUL" is reserved but not r"foo\NUL" if "foo" does not
+ # exist). We err on the side of caution and return True for paths
+ # which are not considered reserved by Windows.
if not parts:
return False
if parts[0].startswith('\\\\'):
# UNC paths are never reserved
return False
- name = parts[-1].partition('.')[0].partition(':')[0].rstrip(' ')
- return name.upper() in self.reserved_names
+ name = parts[-1].partition('.')[0].partition(':')[0].rstrip(' ')
+ return name.upper() in self.reserved_names
def make_uri(self, path):
# Under Windows, file URIs use the UTF-8 encoding.
@@ -264,7 +264,7 @@ class _WindowsFlavour(_Flavour):
return 'file:' + urlquote_from_bytes(path.as_posix().encode('utf-8'))
def gethomedir(self, username):
- if 'USERPROFILE' in os.environ:
+ if 'USERPROFILE' in os.environ:
userhome = os.environ['USERPROFILE']
elif 'HOMEPATH' in os.environ:
try:
@@ -321,9 +321,9 @@ class _PosixFlavour(_Flavour):
def casefold_parts(self, parts):
return parts
- def compile_pattern(self, pattern):
- return re.compile(fnmatch.translate(pattern)).fullmatch
-
+ def compile_pattern(self, pattern):
+ return re.compile(fnmatch.translate(pattern)).fullmatch
+
def resolve(self, path, strict=False):
sep = self.sep
accessor = path._accessor
@@ -340,10 +340,10 @@ class _PosixFlavour(_Flavour):
# parent dir
path, _, _ = path.rpartition(sep)
continue
- if path.endswith(sep):
- newpath = path + name
- else:
- newpath = path + sep + name
+ if path.endswith(sep):
+ newpath = path + name
+ else:
+ newpath = path + sep + name
if newpath in seen:
# Already seen this path
path = seen[newpath]
@@ -430,13 +430,13 @@ class _NormalAccessor(_Accessor):
unlink = os.unlink
- if hasattr(os, "link"):
- link_to = os.link
- else:
- @staticmethod
- def link_to(self, target):
- raise NotImplementedError("os.link() not available on this system")
-
+ if hasattr(os, "link"):
+ link_to = os.link
+ else:
+ @staticmethod
+ def link_to(self, target):
+ raise NotImplementedError("os.link() not available on this system")
+
rmdir = os.rmdir
rename = os.rename
@@ -461,21 +461,21 @@ class _NormalAccessor(_Accessor):
def readlink(self, path):
return os.readlink(path)
- def owner(self, path):
- try:
- import pwd
- return pwd.getpwuid(self.stat(path).st_uid).pw_name
- except ImportError:
- raise NotImplementedError("Path.owner() is unsupported on this system")
-
- def group(self, path):
- try:
- import grp
- return grp.getgrgid(self.stat(path).st_gid).gr_name
- except ImportError:
- raise NotImplementedError("Path.group() is unsupported on this system")
-
-
+ def owner(self, path):
+ try:
+ import pwd
+ return pwd.getpwuid(self.stat(path).st_uid).pw_name
+ except ImportError:
+ raise NotImplementedError("Path.owner() is unsupported on this system")
+
+ def group(self, path):
+ try:
+ import grp
+ return grp.getgrgid(self.stat(path).st_gid).gr_name
+ except ImportError:
+ raise NotImplementedError("Path.group() is unsupported on this system")
+
+
_normal_accessor = _NormalAccessor()
@@ -483,7 +483,7 @@ _normal_accessor = _NormalAccessor()
# Globbing helpers
#
-def _make_selector(pattern_parts, flavour):
+def _make_selector(pattern_parts, flavour):
pat = pattern_parts[0]
child_parts = pattern_parts[1:]
if pat == '**':
@@ -494,7 +494,7 @@ def _make_selector(pattern_parts, flavour):
cls = _WildcardSelector
else:
cls = _PreciseSelector
- return cls(pat, child_parts, flavour)
+ return cls(pat, child_parts, flavour)
if hasattr(functools, "lru_cache"):
_make_selector = functools.lru_cache()(_make_selector)
@@ -504,10 +504,10 @@ class _Selector:
"""A selector matches a specific glob pattern part against the children
of a given path."""
- def __init__(self, child_parts, flavour):
+ def __init__(self, child_parts, flavour):
self.child_parts = child_parts
if child_parts:
- self.successor = _make_selector(child_parts, flavour)
+ self.successor = _make_selector(child_parts, flavour)
self.dironly = True
else:
self.successor = _TerminatingSelector()
@@ -533,9 +533,9 @@ class _TerminatingSelector:
class _PreciseSelector(_Selector):
- def __init__(self, name, child_parts, flavour):
+ def __init__(self, name, child_parts, flavour):
self.name = name
- _Selector.__init__(self, child_parts, flavour)
+ _Selector.__init__(self, child_parts, flavour)
def _select_from(self, parent_path, is_dir, exists, scandir):
try:
@@ -549,45 +549,45 @@ class _PreciseSelector(_Selector):
class _WildcardSelector(_Selector):
- def __init__(self, pat, child_parts, flavour):
- self.match = flavour.compile_pattern(pat)
- _Selector.__init__(self, child_parts, flavour)
+ def __init__(self, pat, child_parts, flavour):
+ self.match = flavour.compile_pattern(pat)
+ _Selector.__init__(self, child_parts, flavour)
def _select_from(self, parent_path, is_dir, exists, scandir):
try:
- with scandir(parent_path) as scandir_it:
- entries = list(scandir_it)
+ with scandir(parent_path) as scandir_it:
+ entries = list(scandir_it)
for entry in entries:
- if self.dironly:
- try:
- # "entry.is_dir()" can raise PermissionError
- # in some cases (see bpo-38894), which is not
- # among the errors ignored by _ignore_error()
- if not entry.is_dir():
- continue
- except OSError as e:
- if not _ignore_error(e):
- raise
- continue
- name = entry.name
- if self.match(name):
- path = parent_path._make_child_relpath(name)
- for p in self.successor._select_from(path, is_dir, exists, scandir):
- yield p
+ if self.dironly:
+ try:
+ # "entry.is_dir()" can raise PermissionError
+ # in some cases (see bpo-38894), which is not
+ # among the errors ignored by _ignore_error()
+ if not entry.is_dir():
+ continue
+ except OSError as e:
+ if not _ignore_error(e):
+ raise
+ continue
+ name = entry.name
+ if self.match(name):
+ path = parent_path._make_child_relpath(name)
+ for p in self.successor._select_from(path, is_dir, exists, scandir):
+ yield p
except PermissionError:
return
class _RecursiveWildcardSelector(_Selector):
- def __init__(self, pat, child_parts, flavour):
- _Selector.__init__(self, child_parts, flavour)
+ def __init__(self, pat, child_parts, flavour):
+ _Selector.__init__(self, child_parts, flavour)
def _iterate_directories(self, parent_path, is_dir, scandir):
yield parent_path
try:
- with scandir(parent_path) as scandir_it:
- entries = list(scandir_it)
+ with scandir(parent_path) as scandir_it:
+ entries = list(scandir_it)
for entry in entries:
entry_is_dir = False
try:
@@ -813,9 +813,9 @@ class PurePath(object):
return NotImplemented
return self._cparts >= other._cparts
- def __class_getitem__(cls, type):
- return cls
-
+ def __class_getitem__(cls, type):
+ return cls
+
drive = property(attrgetter('_drv'),
doc="""The drive prefix (letter or UNC path), if any.""")
@@ -838,11 +838,11 @@ class PurePath(object):
@property
def suffix(self):
- """
- The final component's last suffix, if any.
-
- This includes the leading period. For example: '.txt'
- """
+ """
+ The final component's last suffix, if any.
+
+ This includes the leading period. For example: '.txt'
+ """
name = self.name
i = name.rfind('.')
if 0 < i < len(name) - 1:
@@ -852,11 +852,11 @@ class PurePath(object):
@property
def suffixes(self):
- """
- A list of the final component's suffixes, if any.
-
- These include the leading periods. For example: ['.tar', '.gz']
- """
+ """
+ A list of the final component's suffixes, if any.
+
+ These include the leading periods. For example: ['.tar', '.gz']
+ """
name = self.name
if name.endswith('.'):
return []
@@ -884,10 +884,10 @@ class PurePath(object):
return self._from_parsed_parts(self._drv, self._root,
self._parts[:-1] + [name])
- def with_stem(self, stem):
- """Return a new path with the stem changed."""
- return self.with_name(stem + self.suffix)
-
+ def with_stem(self, stem):
+ """Return a new path with the stem changed."""
+ return self.with_name(stem + self.suffix)
+
def with_suffix(self, suffix):
"""Return a new path with the file suffix changed. If the path
has no suffix, add given suffix. If the given suffix is an empty
@@ -936,21 +936,21 @@ class PurePath(object):
cf = self._flavour.casefold_parts
if (root or drv) if n == 0 else cf(abs_parts[:n]) != cf(to_abs_parts):
formatted = self._format_parsed_parts(to_drv, to_root, to_parts)
- raise ValueError("{!r} is not in the subpath of {!r}"
- " OR one path is relative and the other is absolute."
+ raise ValueError("{!r} is not in the subpath of {!r}"
+ " OR one path is relative and the other is absolute."
.format(str(self), str(formatted)))
return self._from_parsed_parts('', root if n == 1 else '',
abs_parts[n:])
- def is_relative_to(self, *other):
- """Return True if the path is relative to another path or False.
- """
- try:
- self.relative_to(*other)
- return True
- except ValueError:
- return False
-
+ def is_relative_to(self, *other):
+ """Return True if the path is relative to another path or False.
+ """
+ try:
+ self.relative_to(*other)
+ return True
+ except ValueError:
+ return False
+
@property
def parts(self):
"""An object providing sequence-like access to the
@@ -972,16 +972,16 @@ class PurePath(object):
return self._make_child(args)
def __truediv__(self, key):
- try:
- return self._make_child((key,))
- except TypeError:
- return NotImplemented
+ try:
+ return self._make_child((key,))
+ except TypeError:
+ return NotImplemented
def __rtruediv__(self, key):
- try:
- return self._from_parts([key] + self._parts)
- except TypeError:
- return NotImplemented
+ try:
+ return self._from_parts([key] + self._parts)
+ except TypeError:
+ return NotImplemented
@property
def parent(self):
@@ -1105,15 +1105,15 @@ class Path(PurePath):
return self
def __exit__(self, t, v, tb):
- # https://bugs.python.org/issue39682
- # In previous versions of pathlib, this method marked this path as
- # closed; subsequent attempts to perform I/O would raise an IOError.
- # This functionality was never documented, and had the effect of
- # making Path objects mutable, contrary to PEP 428. In Python 3.9 the
- # _closed attribute was removed, and this method made a no-op.
- # This method and __enter__()/__exit__() should be deprecated and
- # removed in the future.
- pass
+ # https://bugs.python.org/issue39682
+ # In previous versions of pathlib, this method marked this path as
+ # closed; subsequent attempts to perform I/O would raise an IOError.
+ # This functionality was never documented, and had the effect of
+ # making Path objects mutable, contrary to PEP 428. In Python 3.9 the
+ # _closed attribute was removed, and this method made a no-op.
+ # This method and __enter__()/__exit__() should be deprecated and
+ # removed in the future.
+ pass
def _opener(self, name, flags, mode=0o666):
# A stub for the opener argument to built-in open()
@@ -1150,7 +1150,7 @@ class Path(PurePath):
try:
other_st = other_path.stat()
except AttributeError:
- other_st = self._accessor.stat(other_path)
+ other_st = self._accessor.stat(other_path)
return os.path.samestat(st, other_st)
def iterdir(self):
@@ -1167,13 +1167,13 @@ class Path(PurePath):
"""Iterate over this subtree and yield all existing files (of any
kind, including directories) matching the given relative pattern.
"""
- sys.audit("pathlib.Path.glob", self, pattern)
+ sys.audit("pathlib.Path.glob", self, pattern)
if not pattern:
raise ValueError("Unacceptable pattern: {!r}".format(pattern))
drv, root, pattern_parts = self._flavour.parse_parts((pattern,))
if drv or root:
raise NotImplementedError("Non-relative patterns are unsupported")
- selector = _make_selector(tuple(pattern_parts), self._flavour)
+ selector = _make_selector(tuple(pattern_parts), self._flavour)
for p in selector.select_from(self):
yield p
@@ -1182,11 +1182,11 @@ class Path(PurePath):
directories) matching the given relative pattern, anywhere in
this subtree.
"""
- sys.audit("pathlib.Path.rglob", self, pattern)
+ sys.audit("pathlib.Path.rglob", self, pattern)
drv, root, pattern_parts = self._flavour.parse_parts((pattern,))
if drv or root:
raise NotImplementedError("Non-relative patterns are unsupported")
- selector = _make_selector(("**",) + tuple(pattern_parts), self._flavour)
+ selector = _make_selector(("**",) + tuple(pattern_parts), self._flavour)
for p in selector.select_from(self):
yield p
@@ -1235,13 +1235,13 @@ class Path(PurePath):
"""
Return the login name of the file owner.
"""
- return self._accessor.owner(self)
+ return self._accessor.owner(self)
def group(self):
"""
Return the group name of the file gid.
"""
- return self._accessor.group(self)
+ return self._accessor.group(self)
def open(self, mode='r', buffering=-1, encoding=None,
errors=None, newline=None):
@@ -1285,15 +1285,15 @@ class Path(PurePath):
with self.open(mode='w', encoding=encoding, errors=errors) as f:
return f.write(data)
- def readlink(self):
- """
- Return the path to which the symbolic link points.
- """
- path = self._accessor.readlink(self)
- obj = self._from_parts((path,), init=False)
- obj._init(template=self)
- return obj
-
+ def readlink(self):
+ """
+ Return the path to which the symbolic link points.
+ """
+ path = self._accessor.readlink(self)
+ obj = self._from_parts((path,), init=False)
+ obj._init(template=self)
+ return obj
+
def touch(self, mode=0o666, exist_ok=True):
"""
Create this file with the given access mode, if it doesn't exist.
@@ -1345,16 +1345,16 @@ class Path(PurePath):
"""
self._accessor.lchmod(self, mode)
- def unlink(self, missing_ok=False):
+ def unlink(self, missing_ok=False):
"""
Remove this file or link.
If the path is a directory, use rmdir() instead.
"""
- try:
- self._accessor.unlink(self)
- except FileNotFoundError:
- if not missing_ok:
- raise
+ try:
+ self._accessor.unlink(self)
+ except FileNotFoundError:
+ if not missing_ok:
+ raise
def rmdir(self):
"""
@@ -1371,49 +1371,49 @@ class Path(PurePath):
def rename(self, target):
"""
- Rename this path to the target path.
-
- The target path may be absolute or relative. Relative paths are
- interpreted relative to the current working directory, *not* the
- directory of the Path object.
-
- Returns the new Path instance pointing to the target path.
+ Rename this path to the target path.
+
+ The target path may be absolute or relative. Relative paths are
+ interpreted relative to the current working directory, *not* the
+ directory of the Path object.
+
+ Returns the new Path instance pointing to the target path.
"""
self._accessor.rename(self, target)
- return self.__class__(target)
+ return self.__class__(target)
def replace(self, target):
"""
- Rename this path to the target path, overwriting if that path exists.
-
- The target path may be absolute or relative. Relative paths are
- interpreted relative to the current working directory, *not* the
- directory of the Path object.
-
- Returns the new Path instance pointing to the target path.
+ Rename this path to the target path, overwriting if that path exists.
+
+ The target path may be absolute or relative. Relative paths are
+ interpreted relative to the current working directory, *not* the
+ directory of the Path object.
+
+ Returns the new Path instance pointing to the target path.
"""
self._accessor.replace(self, target)
- return self.__class__(target)
+ return self.__class__(target)
def symlink_to(self, target, target_is_directory=False):
"""
- Make this path a symlink pointing to the target path.
- Note the order of arguments (link, target) is the reverse of os.symlink.
+ Make this path a symlink pointing to the target path.
+ Note the order of arguments (link, target) is the reverse of os.symlink.
"""
self._accessor.symlink(target, self, target_is_directory)
- def link_to(self, target):
- """
- Make the target path a hard link pointing to this path.
-
- Note this function does not make this path a hard link to *target*,
- despite the implication of the function and argument names. The order
- of arguments (target, link) is the reverse of Path.symlink_to, but
- matches that of os.link.
-
- """
- self._accessor.link_to(self, target)
-
+ def link_to(self, target):
+ """
+ Make the target path a hard link pointing to this path.
+
+ Note this function does not make this path a hard link to *target*,
+ despite the implication of the function and argument names. The order
+ of arguments (target, link) is the reverse of Path.symlink_to, but
+ matches that of os.link.
+
+ """
+ self._accessor.link_to(self, target)
+
# Convenience functions for querying the stat results
def exists(self):
@@ -1426,9 +1426,9 @@ class Path(PurePath):
if not _ignore_error(e):
raise
return False
- except ValueError:
- # Non-encodable path
- return False
+ except ValueError:
+ # Non-encodable path
+ return False
return True
def is_dir(self):
@@ -1441,11 +1441,11 @@ class Path(PurePath):
if not _ignore_error(e):
raise
# Path doesn't exist or is a broken symlink
- # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ return False
+ except ValueError:
+ # Non-encodable path
return False
- except ValueError:
- # Non-encodable path
- return False
def is_file(self):
"""
@@ -1458,11 +1458,11 @@ class Path(PurePath):
if not _ignore_error(e):
raise
# Path doesn't exist or is a broken symlink
- # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ return False
+ except ValueError:
+ # Non-encodable path
return False
- except ValueError:
- # Non-encodable path
- return False
def is_mount(self):
"""
@@ -1473,7 +1473,7 @@ class Path(PurePath):
return False
try:
- parent_dev = self.parent.stat().st_dev
+ parent_dev = self.parent.stat().st_dev
except OSError:
return False
@@ -1481,7 +1481,7 @@ class Path(PurePath):
if dev != parent_dev:
return True
ino = self.stat().st_ino
- parent_ino = self.parent.stat().st_ino
+ parent_ino = self.parent.stat().st_ino
return ino == parent_ino
def is_symlink(self):
@@ -1495,9 +1495,9 @@ class Path(PurePath):
raise
# Path doesn't exist
return False
- except ValueError:
- # Non-encodable path
- return False
+ except ValueError:
+ # Non-encodable path
+ return False
def is_block_device(self):
"""
@@ -1509,11 +1509,11 @@ class Path(PurePath):
if not _ignore_error(e):
raise
# Path doesn't exist or is a broken symlink
- # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ return False
+ except ValueError:
+ # Non-encodable path
return False
- except ValueError:
- # Non-encodable path
- return False
def is_char_device(self):
"""
@@ -1525,11 +1525,11 @@ class Path(PurePath):
if not _ignore_error(e):
raise
# Path doesn't exist or is a broken symlink
- # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ return False
+ except ValueError:
+ # Non-encodable path
return False
- except ValueError:
- # Non-encodable path
- return False
def is_fifo(self):
"""
@@ -1541,11 +1541,11 @@ class Path(PurePath):
if not _ignore_error(e):
raise
# Path doesn't exist or is a broken symlink
- # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ return False
+ except ValueError:
+ # Non-encodable path
return False
- except ValueError:
- # Non-encodable path
- return False
def is_socket(self):
"""
@@ -1557,11 +1557,11 @@ class Path(PurePath):
if not _ignore_error(e):
raise
# Path doesn't exist or is a broken symlink
- # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ # (see http://web.archive.org/web/20200623061726/https://bitbucket.org/pitrou/pathlib/issues/12/ )
+ return False
+ except ValueError:
+ # Non-encodable path
return False
- except ValueError:
- # Non-encodable path
- return False
def expanduser(self):
""" Return a new path with expanded ~ and ~user constructs