This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author filitov
Recipients
Date 2004-04-02.23:26:31
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=642545

Okay, so you talked me in to it. Besides the previous
PyImport_ReloadModule patch, I modified zipimport.c to add
another cache (zip_directory_cache of toc_entry's and
zip_mtime_cache of modification times).

On creation of a new ZipImporter or call to get_module_code,
check_archive_mtime is called, which gets the new mtime and
compares to the cached one. If they are different, it calls
the old read_directory.

read_directory was modified to, instead of creating a brand
new path: [toc_entry] dictionary, clear and re-populate the
same 'files' dictionary. This is so that if multiple
ZipImporters are sharing an archive, and hence already
sharing the same 'files' entry in zip_directory_cache, if
one of them detects a new zip file and has the toc_entry's
reloaded, the other ZipImporters will see the change to (as
they all share the same dictionary).

This was pretty much the same functionality before (sharing
dictionaries), just that now read_directory clears/updates
an exisitng one instead creating its own brand new one.

Also, I had to add a sleep(1) call in testReload to ensure
the modification time stamp would change.

Again, either I don't have permissions to upload files, or I
just can't figure it out, so the patch is at:

http://sh5.beachead.com:8080/~stephen/patch.txt

This is my first foray into Python coding, so double
checking all of the reference counting inc/dec stuff would
be a really good idea.

I also took about 20 minutes to look at adding a reload test
to test_importhooks.py, as suggested, but couldn't get it to
work. I couldn't tell if it was because I was writing a
flawed test (which is what I am suspecting) or if the
PyImport_ReloadModule patch was not working.


History
Date User Action Args
2007-08-23 14:18:46adminlinkissue856103 messages
2007-08-23 14:18:46admincreate