Skip to content

Commit dc5fe8f

Browse files
committed
Implement is_symlink.
Closes #117
1 parent 387dcea commit dc5fe8f

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

newsfragments/117.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implement is_symlink.

tests/test_path.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ def test_eq_hash(self, alpharep):
515515
root = zipfile.Path(alpharep)
516516
assert root in {root}
517517

518-
@__import__('pytest').mark.xfail(reason="Not implemented")
519518
@pass_alpharep
520519
def test_is_symlink(self, alpharep):
521520
root = zipfile.Path(alpharep)

zipp/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import contextlib
66
import pathlib
77
import re
8+
import stat
89
import sys
910

1011
from .compat.py310 import text_encoding
@@ -391,9 +392,11 @@ def match(self, path_pattern):
391392

392393
def is_symlink(self):
393394
"""
394-
Return whether this path is a symlink. Always false (python/cpython#82102).
395+
Return whether this path is a symlink.
395396
"""
396-
return False
397+
info = self.root.getinfo(self.at)
398+
mode = info.external_attr >> 16
399+
return stat.S_ISLNK(mode)
397400

398401
def glob(self, pattern):
399402
if not pattern:

0 commit comments

Comments
 (0)