diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2022-11-26 18:05:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-26 18:05:41 (GMT) |
commit | 93f22d30eb7bf579d511b1866674bc1c2513dde9 (patch) | |
tree | a81c5e228d9146fe8cfa0edf7c2f1f5098f427ff /Lib/zipfile | |
parent | 5f8898216e7b67b7de6b0b1aad9277e88bcebfdb (diff) | |
download | cpython-93f22d30eb7bf579d511b1866674bc1c2513dde9.zip cpython-93f22d30eb7bf579d511b1866674bc1c2513dde9.tar.gz cpython-93f22d30eb7bf579d511b1866674bc1c2513dde9.tar.bz2 |
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.
Diffstat (limited to 'Lib/zipfile')
-rw-r--r-- | Lib/zipfile/_path.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Lib/zipfile/_path.py b/Lib/zipfile/_path.py index 67ef07a..aea17b6 100644 --- a/Lib/zipfile/_path.py +++ b/Lib/zipfile/_path.py @@ -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. |