Martin Maney <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > You don't need to do that, you can just "monkey patch" the _EndRecData > > function. > > For a quick & dirty test, sure. If I were certain I'd only ever use > this on one machine for a limited time (viz, no system upgrades that > replace zipfile.py) it might suffice. But that doesn't generalize > worth a damn.
>From the above I don't think you've understood the concept of monkey patching - it is run time patching. You patch the zipfile module from your code - no messing with the installed python needed. Eg something like :- ------------------------------------------------------------ import zipfile OriginalEndRecData = zipfile._EndRecData def MyEndRecData(fpin): """ Return data from the "End of Central Directory" record, or None. """ # Try the builtin one first endrec = OriginalEndRecData(fpin) if endrec is None: # didn't work so do something extra # you fill this bit in! pass return endrec zipfile._EndRecData = MyEndRecData # Now use your run time patched zipfile module as normal ------------------------------------------------------------ It isn't ideal, but it certainly does generalise. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list