@@ -237,9 +237,7 @@ def __repr__(self):
237237
238238# _zip_searchorder defines how we search for a module in the Zip
239239# archive: we first search for a package __init__, then for
240- # non-package .pyc, and .py entries. The .pyc entries
241- # are swapped by initzipimport() if we run in optimized mode. Also,
242- # '/' is replaced by path_sep there.
240+ # non-package .pyc, and .py entries.
243241_zip_searchorder = (
244242 (path_sep + '__init__.pyc' , True , True ),
245243 (path_sep + '__init__.py' , False , True ),
@@ -570,7 +568,7 @@ def _get_zlib_decompress_func():
570568
571569 global _importing_zlib
572570 if _importing_zlib :
573- # Someone has a zlib.py[co] in their Zip file
571+ # Someone has a zlib.pyc in their Zip file
574572 # let's avoid a stack overflow.
575573 _bootstrap ._verbose_message ('zipimport: zlib UNAVAILABLE' )
576574 raise ZipImportError ("can't decompress data; zlib not available" )
@@ -601,7 +599,7 @@ def _get_zstd_decompressor_class():
601599
602600 global _importing_zstd
603601 if _importing_zstd :
604- # Someone has a _zstd.py[co] in their Zip file
602+ # Someone has a _zstd.pyc in their Zip file
605603 # let's avoid a stack overflow.
606604 _bootstrap ._verbose_message ("zipimport: zstd UNAVAILABLE" )
607605 raise ZipImportError ("can't decompress data; zstd not available" )
@@ -705,9 +703,9 @@ def _eq_mtime(t1, t2):
705703 return abs (t1 - t2 ) <= 1
706704
707705
708- # Given the contents of a .py[co] file, unmarshal the data
709- # and return the code object. Raises ImportError it the magic word doesn't
710- # match, or if the recorded .py[co] metadata does not match the source .
706+ # Given the contents of a .pyc file, unmarshal the data
707+ # and return the code object. Raises ImportError if the magic word doesn't
708+ # match, or if the recorded .pyc hash fails validation .
711709def _unmarshal_code (self , pathname , fullpath , fullname , data ):
712710 exc_details = {
713711 'name' : fullname ,
@@ -781,8 +779,8 @@ def _parse_dostime(d, t):
781779# or (0, 0) if no source is available.
782780def _get_mtime_and_size_of_source (self , path ):
783781 try :
784- # strip 'c' or 'o' from *.py[co]
785- assert path [ - 1 :] in ( 'c' , 'o ' )
782+ # strip 'c' from *.pyc
783+ assert path . endswith ( '.pyc ' )
786784 path = path [:- 1 ]
787785 toc_entry = self ._get_files ()[path ]
788786 # fetch the time stamp of the .py file for comparison
@@ -799,8 +797,8 @@ def _get_mtime_and_size_of_source(self, path):
799797# contents of the matching .py file, or None if no source
800798# is available.
801799def _get_pyc_source (self , path ):
802- # strip 'c' or 'o' from *.py[co]
803- assert path [ - 1 :] in ( 'c' , 'o ' )
800+ # strip 'c' from *.pyc
801+ assert path . endswith ( '.pyc ' )
804802 path = path [:- 1 ]
805803
806804 try :
0 commit comments