You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
zipfile.Path.is_symlink() raises KeyError for the archive root #153529
zipfile.Path.is_symlink() raises a KeyError when used on the archive root. The root is a valid Path object, and other predicate methods do not raise errors in this case.
True
False
Traceback (most recent call last):
File "d:\Open Source\cpython\repro.py", line 16, in <module>
print(root.is_symlink())
~~~~~~~~~~~~~~~^^
File "C:\Users\vinee\AppData\Local\Programs\Python\Python315\Lib\zipfile\_path\__init__.py", line 417, in is_symlink
info = self.root.getinfo(self.at)
File "C:\Users\vinee\AppData\Local\Programs\Python\Python315\Lib\zipfile\_path\__init__.py", line 140, in getinfo
return super().getinfo(name)
~~~~~~~~~~~~~~~^^^^^^
File "C:\Users\vinee\AppData\Local\Programs\Python\Python315\Lib\zipfile\__init__.py", line 1646, in getinfo
raise KeyError(
'There is no item named %r in the archive' % name)
KeyError: "There is no item named '' in the archive"
Path.is_symlink() unconditionally calls self.root.getinfo(self.at). For the archive root, self.at == "", so ZipFile.getinfo("") raises KeyError. Unlike is_dir(), is_symlink() does not special-case the root.
Since the archive root is conceptually a directory rather than a symlink, I would expect:
root.is_symlink() ==False
This change would make its behavior match the other predicate methods, like is_dir() and is_file(), which do not raise errors when called on the archive root.
Activity
StanFromIreland commentedon Jul 11, 2026
Duplicate of #152762