55import pickle
66import stat
77import sys
8- import time
98import unittest
109
1110import jaraco .itertools
1514
1615from ._test_params import Invoked , parameterize
1716from .compat .py39 .os_helper import FakePath , temp_dir # type: ignore[import-not-found]
17+ from .compat .py313 import ForArchive
1818
1919
2020def _make_link (info : zipfile .ZipInfo ): # type: ignore[name-defined]
@@ -628,7 +628,7 @@ def test_backslash_not_separator(self):
628628 """
629629 data = io .BytesIO ()
630630 zf = zipfile .ZipFile (data , "w" )
631- zf .writestr (DirtyZipInfo . for_name ("foo\\ bar" , zf ), b"content" )
631+ zf .writestr (DirtyZipInfo ("foo\\ bar" ). _for_archive ( zf ), b"content" )
632632 zf .filename = ''
633633 root = zipfile .Path (zf )
634634 (first ,) = root .iterdir ()
@@ -643,28 +643,11 @@ def test_interface(self, alpharep):
643643 assert isinstance (zf , Traversable )
644644
645645
646- class DirtyZipInfo (zipfile .ZipInfo ):
646+ class DirtyZipInfo (zipfile .ZipInfo , ForArchive ):
647647 """
648648 Bypass name sanitization.
649649 """
650650
651651 def __init__ (self , filename , * args , ** kwargs ):
652652 super ().__init__ (filename , * args , ** kwargs )
653653 self .filename = filename
654-
655- @classmethod
656- def for_name (cls , name , archive ):
657- """
658- Construct the same way that ZipFile.writestr does.
659-
660- TODO: extract this functionality and re-use
661- """
662- self = cls (filename = name , date_time = time .localtime (time .time ())[:6 ])
663- self .compress_type = archive .compression
664- self .compress_level = archive .compresslevel
665- if self .filename .endswith ('/' ): # pragma: no cover
666- self .external_attr = 0o40775 << 16 # drwxrwxr-x
667- self .external_attr |= 0x10 # MS-DOS directory flag
668- else :
669- self .external_attr = 0o600 << 16 # ?rw-------
670- return self
0 commit comments