[Python-Dev] Freezing unicode codecs.

Finn Bock bckfnn@worldonline.dk
Thu, 10 Aug 2000 22:17:47 GMT


While porting the unicode API and the encoding modules to JPython I came
across a problem which may also (or maybe not) exists in CPython.

jpythonc is a compiler for jpython which try to track dependencies
between modules in an attempt to detect which modules an application or
applet uses. I have the impression that some of the freeze tools for
CPython does something similar.

A call to unicode("abc", "cp1250") and "abc".encode("cp1250") will cause
the encoding.cp1250 module to be loaded as a side effect. The freeze
tools will have a hard time figuring this out by scanning the python
source.


For JPython I'm leaning towards making it a requirement that the
encodings must be loading explicit from somewhere in application. Adding


   import encoding.cp1250

somewhere in the application will allow jpythonc to include this python
module in the frozen application.

How does CPython solve this?


PS. The latest release of the JPython errata have full unicode support
and includes the "sre" module and unicode codecs.

    http://sourceforge.net/project/filelist.php?group_id=1842


regards,
finn