[Python-Dev] Should Python's library modules be written to help the freeze tools? (original) (raw)

Tony Meyer t-meyer at ihug.co.nz
Sun Jan 30 23:05:57 CET 2005


The Python 2.4 Lib/bsddb/init.py contains this:

"""

for backwards compatibility with python versions older than 2.3, the

iterator interface is dynamically defined and added using a mixin

class. old python can't tokenize it due to the yield keyword.

if sys.version >= '2.3': exec """ import UserDict from weakref import ref class _iter_mixin(UserDict.DictMixin): ... """

Because the imports are inside an exec, modulefinder (e.g. when using bsddb with a py2exe built application) does not realise that the imports are required. (The requirement can be manually specified, of course, if you know that you need to do so).

I believe that changing the above code to:

""" if sys.version >= '2.3': import UserDict from weakref import ref exec """ class _iter_mixin(UserDict.DictMixin): """

Would still have the intended effect and would let modulefinder do its work.

The main question (to steal Thomas's words) is whether the library modules should be written to help the freeze tools - if the answer is 'yes', then I'll submit the above as a patch for 2.5.

Thanks!

=Tony.Meyer



More information about the Python-Dev mailing list