Manual backport of #160103 to 3.14; miss-islington could not apply it cleanly.
The conflict: zipfile/_path/_functools.py does not exist on 3.14 — it arrived with the zipp 3.23 refresh in gh-135276, which landed in 3.15. Rather than introduce a new private module and a none_as helper on a maintenance branch for a single call site, __str__ tests for None inline:
def __str__(self):
root = self.root.filename
if root is None:
root = ':zipfile:'
return posixpath.join(root, self.at) if self.at else root
Note this cannot be shortened to self.root.filename or ':zipfile:': a zipfile whose filename is the empty string must keep rendering as empty, which test_unsupported_names covers.
The two new tests also use this branch's self.fixtures.enter_context idiom rather than self.enterContext, since gh-81954 — which introduced the enterContext style in this file along with a ResourceWarning on implicit ZipFile close — is main-only.
Verified on 3.14: test_zipfile passes (388 tests), including test_unsupported_names and the two new tests.
(cherry picked from commit ba96fab)
Co-authored-by: Jason R. Coombs [email protected]
🤖 Generated with Claude Code