mirror of
https://github.com/python/cpython.git
synced 2025-08-08 02:48:55 +00:00
gh-98108: Add limited pickleability to zipfile.Path (GH-98109)
* gh-98098: Move zipfile into a package. * Moved test_zipfile to a package * Extracted module for test_path. * Add blurb * Add jaraco as owner of zipfile.Path. * Synchronize with minor changes found at jaraco/zipp@d9e7f4352d. * gh-98108: Sync with zipp 3.9.1 adding pickleability.
This commit is contained in:
parent
5f8898216e
commit
93f22d30eb
6 changed files with 110 additions and 22 deletions
|
@ -62,7 +62,25 @@ def _difference(minuend, subtrahend):
|
|||
return itertools.filterfalse(set(subtrahend).__contains__, minuend)
|
||||
|
||||
|
||||
class CompleteDirs(zipfile.ZipFile):
|
||||
class InitializedState:
|
||||
"""
|
||||
Mix-in to save the initialization state for pickling.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.__args = args
|
||||
self.__kwargs = kwargs
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __getstate__(self):
|
||||
return self.__args, self.__kwargs
|
||||
|
||||
def __setstate__(self, state):
|
||||
args, kwargs = state
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class CompleteDirs(InitializedState, zipfile.ZipFile):
|
||||
"""
|
||||
A ZipFile subclass that ensures that implied directories
|
||||
are always included in the namelist.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue