From dc5fe8f4dd31e551f9bf76b5403e64f06f72a0c7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 26 May 2024 12:11:22 -0400 Subject: [PATCH] Implement is_symlink. Closes #117 --- newsfragments/117.feature.rst | 1 + tests/test_path.py | 1 - zipp/__init__.py | 7 +++++-- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 newsfragments/117.feature.rst diff --git a/newsfragments/117.feature.rst b/newsfragments/117.feature.rst new file mode 100644 index 0000000..239a902 --- /dev/null +++ b/newsfragments/117.feature.rst @@ -0,0 +1 @@ +Implement is_symlink. \ No newline at end of file diff --git a/tests/test_path.py b/tests/test_path.py index 418771c..bbf39b2 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -515,7 +515,6 @@ def test_eq_hash(self, alpharep): root = zipfile.Path(alpharep) assert root in {root} - @__import__('pytest').mark.xfail(reason="Not implemented") @pass_alpharep def test_is_symlink(self, alpharep): root = zipfile.Path(alpharep) diff --git a/zipp/__init__.py b/zipp/__init__.py index df3293a..b08016c 100644 --- a/zipp/__init__.py +++ b/zipp/__init__.py @@ -5,6 +5,7 @@ import contextlib import pathlib import re +import stat import sys from .compat.py310 import text_encoding @@ -391,9 +392,11 @@ def match(self, path_pattern): def is_symlink(self): """ - Return whether this path is a symlink. Always false (python/cpython#82102). + Return whether this path is a symlink. """ - return False + info = self.root.getinfo(self.at) + mode = info.external_attr >> 16 + return stat.S_ISLNK(mode) def glob(self, pattern): if not pattern: