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: __str__ and relative_to crash with TypeError when ZipFile was opened from a file-like object #162127
When zipfile.Path is constructed from an in-memory io.BytesIO or any file-like object (where ZipFile.filename is None), calling str(path) or path.relative_to(other) crashes with TypeError: expected str, bytes or os.PathLike object, not NoneType.
str() error: expected str, bytes or os.PathLike object, not NoneType
relative_to() error: expected str, bytes or os.PathLike object, not NoneType
Traceback:
File ".../lib/python3.13/zipfile/_path/__init__.py", line 431, in relative_to
return posixpath.relpath(str(self), str(other.joinpath(*extra)))
File ".../lib/python3.13/zipfile/_path/__init__.py", line 434, in __str__
return posixpath.join(self.root.filename, self.at)
File "<frozen posixpath>", line 77, in join
TypeError: expected str, bytes or os.PathLike object, not NoneType
Expected Behavior:
str(path) should handle self.root.filename is None without crashing (e.g. returning self.at).
relative_to between two paths within the same zip archive should compute the relative path between self.at and other.at without requiring self.root.filename.
When self.root is a ZipFile initialized with a stream or buffer rather than a file path, self.root.filename is None. posixpath.join(None, self.at) raises TypeError.
Activity