[Python-checkins] r58727 - sandbox/trunk/import_in_py/zipimport_/zipimport.py

brett.cannon python-checkins at python.org
Wed Oct 31 05:33:31 CET 2007


Author: brett.cannon
Date: Wed Oct 31 05:33:30 2007
New Revision: 58727
Modified:
 sandbox/trunk/import_in_py/zipimport_/zipimport.py
Log:
Change constructor so that even an empty argument is okay; someone might have a
file named 'None' that is a zip file.
Modified: sandbox/trunk/import_in_py/zipimport_/zipimport.py
==============================================================================
--- sandbox/trunk/import_in_py/zipimport_/zipimport.py	(original)
+++ sandbox/trunk/import_in_py/zipimport_/zipimport.py	Wed Oct 31 05:33:30 2007
@@ -5,9 +5,11 @@
 + _zip_directory_cache uses instances of zipfile.ZipInfo as values instead
 of tuples.
 + zipimporter.prefix does not necessarily end in a path separator.
- + ZipImporterError is raised if the argument to zipimporter.__init__ does
+ + ZipImportError is raised if the argument to zipimporter.__init__ does
 not contain a path to a zip file; 2.x version allows for opening a any
 file but raises errors later on during usage.
+ + ZipImportError is raised even if None is passed in to
+ zipimport.__init__.
 
 """
 import importlib
@@ -45,15 +47,13 @@
 than a zip file is passed in then ZipImportError is raised.
 
 """
- if not archivepath:
- raise TypeError("argument must represent a path to a zip file")
 path = archivepath
 while path and path != os.sep:
 if zipfile.is_zipfile(path):
 break
 path = os.path.split(path)[0]
 else:
- raise ZipImportError("%s is not a zip file" % archivepath)
+ raise ZipImportError("%s is not a path to a zip file" % archivepath)
 self.archive = os.path.abspath(path) # Path to zip file.
 self.prefix = archivepath[len(self.archive)+1:] # Package directory.
 if not self.archive in _zip_directory_cache:


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /