From 0ee10cac6cf01a92ca6c5fb90bfa3a2312ad3d6c Mon Sep 17 00:00:00 2001 From: barneygale Date: Sat, 2 Sep 2023 18:34:51 +0100 Subject: [PATCH] Make `_PathBase.is_junction()` immediately return false. --- Lib/pathlib.py | 19 ++++--------------- Lib/test/test_pathlib.py | 1 - 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 148508d55bd67a..03673d5f541f34 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -919,21 +919,10 @@ def is_junction(self): """ Whether this path is a junction. """ - try: - self.lstat() - # Junctions are a Windows-only feature, not present in POSIX nor - # the majority of virtual filesystems. There is no cross-platform - # idiom to check for junctions (using stat().st_mode). And so this - # default implementation returns false if lstat() doesn't raise. - return False - except OSError as e: - if not _ignore_error(e): - raise - # Path doesn't exist - return False - except ValueError: - # Non-encodable path - return False + # Junctions are a Windows-only feature, not present in POSIX nor the + # majority of virtual filesystems. There is no cross-platform idiom + # to check for junctions (using stat().st_mode). + return False def is_block_device(self): """ diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index be24601e653392..de07a67680a3d2 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1604,7 +1604,6 @@ def test_unsupported_operation(self): self.assertRaises(e, p.is_char_device) self.assertRaises(e, p.is_fifo) self.assertRaises(e, p.is_socket) - self.assertRaises(e, p.is_junction) self.assertRaises(e, p.open) self.assertRaises(e, p.read_bytes) self.assertRaises(e, p.read_text)