Skip to content

Commit

Permalink
Make _PathBase.is_junction() immediately return false.
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Sep 2, 2023
1 parent c9f0f20 commit 0ee10ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
19 changes: 4 additions & 15 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0ee10ca

Please sign in to comment.